Everybody to help me have a look at, this is my pack code:
SelectedAsset is I choose the prefab in the Project panel, after traversal path assigned to resoucesAssets
for (int I=0; i{
SourcePath=AssetDatabase. GetAssetPath (SelectedAsset [I]);
ResoucesAssets [I]=sourcePath;
}
And then directly packaging, here I use AssetBundleBuild [] array, don't know if this problem,
BuildPipeline. BuildAssetBundles (targetPath);
Is my next to unpack the code:
First of all is to download the complete the manifest file and print here (www.error); There is no error
WWW WWW=WWW.LoadFromCacheOrDownload (mainUrl, 0);
Yield return WWW.
AssetBundleManifest manifest=new AssetBundleManifest ();
if (! String. IsNullOrEmpty (www.error))
{
Print (www.error);
}
The else
{
AssetBundle manifestBundle=www.assetBundle;
The manifest=manifestBundle. LoadAsset (" AssetBundleManifest ") as AssetBundleManifest;
ManifestBundle. Unload (false);
}
And then download the cube packaging file, print (wwwGoal. Error); No error, but it is here to Instantiate (goal); Tell me the result is null,
WWW wwwGoal=WWW.LoadFromCacheOrDownload (path + realName + the extension, the manifest. GetAssetBundleHash (realName + extension), 0).
Yield return wwwGoal;
if (! String. IsNullOrEmpty (wwwGoal. Error))
{
Print (wwwGoal. Error);
}
The else
{
AssetBundle ab=wwwGoal. AssetBundle;
GameObject goal=ab. LoadAsset (realName + extension) as GameObject.
If (goal!=null)
{
Instantiate (goal);
Ab. Unload (false);
}
}
If this is possible, packaging can be successful, 45 KB size also is normal, I have seen the total that the manifest file, also the info about the cube file name, but not in fact cube is packaged in?
By this problem for several days, stackoverflow also asked, has not had a clear answer, new beg great god help!!!!!!!!!!!!!!!!!!!
CodePudding user response:
You can use the vs breakpoint debugging, debugging time have a look at all the resources in the assetBundle nameIn addition, Unity5. X, inside the AssetBundle resources are generally lowercase!
Assets/Textures/Amy polumbo ng, for example, when the Load is Assets LoadAssets
CodePudding user response:
ManifestBundle dependencies, is should be kept in May because of dependence on cause the failure of you instantiated, cube rely on resource loading have not come all cannot instantiate the cube,CodePudding user response:
I've never used 5. X packaging, but 4 x of this kind of situation I encountered, packaging is successful, loading is successful, but when you visit asset at runtime, found him to be null, is likely to be the one reason is that you pack, where the play, didn't pay attention to packaging method has two parameters, a synchronous load asset, are used to provide an asynchronous loading is used to array, the two you have to understand