2D Toolkit Forum

2D Toolkit => Support => Topic started by: slydog on September 28, 2012, 09:41:07 pm

Title: Access Sprite GameObject from a batch
Post by: slydog on September 28, 2012, 09:41:07 pm
Once I commit the batch, the sprite game objects disappear from the hierarchy (as designed I assume).
Since I want batching, how to I reference a specific sprite from another script?

Background:  I have a simple arrow sprite that represents the wind direction.  I have a WindManager that is a static class with a windSprite property, and I want to specify the wind sprite via a 'SetWindSprite()' method or something.

I'll do this via my GameManager, ideally through a public property I can set in the inspector.  I have it working now that I can drag my sprite into the GameManager script, and it works fine when I call 'SetWindSprite()' in my WindManager.  But with batching, I have nothing to drag?!  I hope this makes sense.
Title: Re: Access Sprite GameObject from a batch
Post by: unikronsoftware on September 28, 2012, 09:57:40 pm
The static sprite batcher is just for static backgrounds and other static objects. In this case, your object doesn't have to be a static sprite batcher - you'll still get batching from the Unity dynamic batching system. You don't HAVE to use the static sprite batcher to get batching, its just a much more efficient way to do it when everything is static.