IOS stripping and Instantiate

I am calling Object.Instantiate on iphone with www load asset bundle.

When I call stripping, it doesn’t load the file with some missing ID error.

So I included the model and texture, and the problem is gone… However I include another model and texture it doesn’t work anymore, so Do I have to have the exact same model to be able to instantiate the object?

That would have no use on loading assets in runtime if I had to store the exact model in project anyways…

Thanks ahead.

Can you post the code you are using to load the bundle and instantiate the assets? Are you saying that this only happens when you use stripping?

I saw somewhere else it has the same problem, this is the problem I got from xcode:

Could not produce class with ID 33

Could not produce class with ID 23

	public IEnumerator WaitLoading(WWW download) {
    	yield return download;     	
	}


	private void GenerateModel() {
				
			assetBundle = download.assetBundle;
			
			// Alternatively you can also load an asset by name (assetBundle.Load("my asset name"))
			GameObject go= (GameObject)assetBundle.mainAsset;
			
			if (go != null)
				instanced = (GameObject)UnityEngine.Object.Instantiate(go);
			else
				Debug.Log("Couldnt load resource");	
		
		
	}
	
	private void StartDownload () {
	
		download = new WWW ("http://mydownloads/AssetBundles/" + url);
	
		
		
		StartCoroutine(WaitLoading(download));
	


	}
	
	
	void Update()
	{
		if(download != null)
		{
			if(download.isDone  !Generated)
			{
				GenerateModel();
				Generated = true;
			}
		}	
			
		
		
		
	}
	
	


	void OnGUI()
	{
		GUILayout.Space(guiOffset);
		GUILayout.BeginHorizontal();
		if (download == null)
		{
		
			if (GUILayout.Button("Download " + url))
				StartDownload();	
		}
		else
		{
			if (download.error == null)
			{
				int progress =(int)(download.progress * 100);
				GUILayout.Label(progress + "%");	
				
				
				
			
				if (download.isDone  GUILayout.Button("Unload Resource")	)
				{
					// Destroy the instantiated object
					Destroy(instanced);
					// Dispose the WWW class
					// (This happens automatically from the GC, but you can do it explicitly to make sure it happens early on)
					download.Dispose();
					download = null;
					
					Generated = false;

					// Unload the whole asset bundles and any loaded assets
					assetBundle.Unload (true);
					assetBundle = null;
				}
				
				
			}
			else
			{
				GUILayout.Label(download.error);		
			}	
		}
		GUILayout.EndHorizontal();
	}

Reference this thread. I’ve asked the same question and got resolved.

http://forum.unity3d.com/threads/85056-Instantiate(www.assetBundle.mainAsset)-cause-EXC_BAD_ACCESS(SIGABRT)

Selected dependencies had Prefab, Material, MeshFilter, MeshRenderer, Animation and Texture2D, I declared all these variables…

Now it actually doesn’t crash at 0%, it loads the file to 100%, but after that, it gives me an error:
“Could not produce class with ID 43”, what’s that component anybody know?

Got it fixed, rather than include MeshFilter and MeshRenderer, Just declared Mesh as a dummy variable, and the problem went away.

im freshman,
and confused that
How to declared Mesh as a dummy variable?
Can anyone give me some details?

put at the top:

private Mesh meshDummy; :wink:

I still could not make it work,
I put this declaration at the top of a script atatched to a prefab in the bundle assets package made by “BuildPipeline.BuildAssetBundle”.

but still failed with “Could not produce class with ID 137” when “Instantiate(www.assetBundle.mainAsset);” is called.

Did you rebuild the player?

asset bundles don’t contain any code at all, its all in the application. asset bundles only have the “hints” on which script is attached

find the problem,
I made a mistake, I declared the dummy variable using public.

I changed to private,and it works :razz:

but…
when i pack a prefab with animation in the modal, it failed again.
so…

there is an alternative way, thats the link.xml file as describe here: Unity - Manual: Optimizing the size of the built iOS Player

Unsure if that helps on inbuilt ones but its worht a try.

It seems additional variable of SkinedMeshRenderer is need for model with animation.
I add it and it seems work fine.

and the link.xml seems work fine too.
for I not need to change the package by this way, I 'd select this way. :slight_smile: