Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gak

Pages: [1]
1
I did a totally newbie thing and forgot that Resorce.load() only looks in Resources folders. Thanks for pointing that out.

All I had to do is move the generated prefab (containing the tk2dSpriteCollectionData component) into the Resources folder. When I commit any changes (via the tk2dSpriteCollection editor), it appears to update the moved prefab.

2
Trying to get the static sprite batcher going via this example: http://www.unikronsoftware.com/2dtoolkit/docs/2.00/advanced/scripting_static_sprite_batcher.html

Unfortunately I'm not having much like getting the Sprite Collection.

I have one sprite collection in my project, under assets, called "Sprites", and I tried to get the component via this bit of code:

Code: [Select]
GameObject sprites = (GameObject)Resources.Load("Sprites");
tk2dSpriteCollectionData spriteCollection = sprites.GetComponent<tk2dSpriteCollectionData>();

This causes an error saying: "NullReferenceException: Object reference not set to an instance of an object", which makes me believe that getting the Sprites prefab via Resources.Load might not be the right way of accessing the sprite collection.

How would I do this? What is the usual way of accessing your sprite collection(s) via code?

Thanks, Gerald

Pages: [1]