2D Toolkit Forum
2D Toolkit => Support => Topic started by: zyy on August 08, 2013, 04:52:49 am
-
tk2dSprite and it's tk2dSpriteCollectionData is builded in Unity's Editor,
Only need re-link the texture at runtime.
Because need pack the texture in assetBundle, and download at runtime;
this is my test code,
but get a err message :
"UnassignedReferenceException: The variable material of 'tk2dSpriteCollectionData' has not been assigned.
You probably need to assign the material variable of the tk2dSpriteCollectionData script in the inspector."
GameObject nol = GameObject.Find( "normal" );
tk2dSprite script = (tk2dSprite)nol.GetComponent( "tk2dSprite" );
tk2dSpriteCollectionData col = script.Collection;
Material mat = col.material;
mat.SetTexture( "txt", loadTex );
//Texture tex = mat.mainTexture;
//tex = loadTex;
-
What are you trying to do here? Is there any reason you're not putting the asset bundle into the atlas itself?
-
What are you trying to do here? Is there any reason you're not putting the asset bundle into the atlas itself?
Thanks your reply.
putting the asset bundle into the atlas itself?
I want to pack the atlas into a asset bundle;
download it from httpServer when the client at runtime, and re-link it with tk2dSprite , it's tk2dSpriteCollectionData,
(Sprite and SpriteCollectionData has been created in unityEditor not at runtime)
-
You can find some sample code to create and use sprite collection asset bundles on this thread:
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,2277.0.html
Hope that helps.
-
Thanks~