Hello,
I have a project that successfully uses TK2D for several sets of Sprite Animations. I now need to expand the project to several flavors and will load assets using AssetBundles and instantiate the loaded prefabs.
I exported all the art, sprite, animation, and prefab objects into an empty project. This was related to a thread discussing asset isolation. TK2D was imported. I have been experimenting with both forms of ExportAssetBundles... one method involves creating separate bundles for Sprites, Animations, then Prefabs without dependencies; the other involves packing the bundle at the Prefab level with dependencies.
In the main program, I have been loading each of the asset bundles (in order) with LoadAll() for Sprites and Animations; then explicit load and instantiation for each of the prefabs.
The Sprites seem to work - though they seem to be misbehaving someone on being active or not active. But with Animations - I get the first frame of the animation - the properties/watch suggest all frames are referenced, its playing, has fps, it is not paused, etc. But nothing plays.
I have seen references to including SpriteCollectionData data component in the bundle. I followed a reference a Demo Sprite Collection and copying the data part to my assetbundle but its only 6k, not 28k as suggested. This whole part is a bit confusing.
So here is a bit of code on how I am trying to load this (in a non-dependency way)
void LoadSpritesBundle ()
{
var assetPath = "file://" + Application.dataPath + "/Bundles/MySceneSprites.unity3d";
// Open the Asset
WWW www =
WWW.LoadFromCacheOrDownload (assetPath, 1);
// Get the Asset Bundle
AssetBundle bundle =
www.assetBundle; // Load all the assets
bundle.LoadAll ();
}
void LoadAnimsBundle()
{
var assetPath = "file://" + Application.dataPath + "/Bundles/MySceneAnims.unity3d";
// Open the Asset
WWW www =
WWW.LoadFromCacheOrDownload (assetPath, 1);
// Get the Asset Bundle
AssetBundle bundle =
www.assetBundle; // Load all the assets
bundle.LoadAll ();
}
void LoadPrefabBundle()
{
GameObject myObject;
var assetPath = "file://" + Application.dataPath + "/Bundles/MyScenePrefabs.unity3d";
// Open the Asset
WWW www =
WWW.LoadFromCacheOrDownload (assetPath, 1);
// Get the Asset Bundle
AssetBundle bundle =
www.assetBundle; // Load
myObject = bundle.Load ( "MyObject", typeof(GameObject)) as GameObject;
Instantiate (myObject);
//Instantiate (myObject, new Vector3(87.0f,81.0f,-5.1f),Quaternion.identity);
myObjectAnimatedSpriteArray[0] = myObject.GetComponent<tk2dAnimatedSprite>();
....
}
I obviously gone on a tangent. But the info I have digested so far seems to have confused me a bit... particularly the SpriteCollection Data part.
Help me find my way back