Thanks again for the response. I went ahead and tested out your suggestions, and am able to load sprite collections dynamically and associate them with sprites at runtime and programmatically.
One odd quirk I found is that... when I use the code below, I am able to create a sprite, dynamically load the sprite collection, and see it in the game. However, when I click on the game object that i created with the sprite, everything reverts back to a different state (in this case, it turns into the built-in spider sprite collection with the sprite being the body. I assume that when the inspector attempts to view this, that is finds something it doesn't like and somehow reinitailizes the sprite to defaults?
To test this, I loaded the polygon colliders scene in the sample. I selected the "data" prefab in DemoSpriteCollection in the project and saved it into a resources directory file named "bubba".
I then added code in the GameController reload method to do this:
// works, but selecting the game object reverts its properties to being a spider.
// GameObject go = new GameObject();
// tk2dSprite sprite = go.AddComponent<tk2dSprite>();
// sprite.collection = Resources.Load ("bubba", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
// sprite.spriteId = sprite.GetSpriteIdByName("2dtoolkit_logo");
// works, but selecting the game object reverts its properties to being a spider.
GameObject go = new GameObject();
tk2dSprite sprite = go.AddComponent<tk2dSprite>();
tk2dSpriteCollectionData collection = Resources.Load ("bubba", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
sprite.SwitchCollectionAndSprite(collection, 12);
sprite.Build();
sprite.scale = new Vector3(10, 10, 10);
I see the sprite fine in the game view. Clicking the "Game Object" in the hierarchy view will flip it back to spider mode.
Any idea what I'm doing wrong? It'll be important for us to be able to click and view properties on sprites dynamically generated in game, so I'm hoping this is just something I'm not seeing.
Thanks!