User Tools

Site Tools


scripting:propertiescollection

Properties Collection

Properties Collection store all Properties of a Material, this is especially useful for Animations. The Collections are stored as Asset Files in your project. You can either create a new blank Collection or use an existing Material as a source.

Handling Collections

Creation

There are several ways for creating Collections, the most simple is using the NGS Widget.

Click on the Generate [Blank] Button and a Dialog to save the Properties Collection Asset will appear. If you have an Sprite with an NextGenSprites Material selected, then you can also use Generate [from Selection] button which will do as the name implies.

Alternatively and more convenient, you can also Generate a Collection from a Source Material by clicking on the Extras Panel and selecting from there the “Export Properties” option.

Loading

As you saw in the image before, you can either import an existing Collection from the Extras Panel or Widget.

Properties

The Properties Collection allows you to store all Properties that are used by the NextGenSprites Shaders. Floats, Tints, Textures and even the toggle state for the Shader Features!

Besides the Properties, each Properties Collections can have a Name assigned which can be later used by the Manager or Controller to update the Material by the matching name.

Manager

The Manager is responsible for converting at runtime the Properties Collections into a cache of Materials. There are two variations, Host and Solo.

Manager Solo

The Solo Manager handles the creation of the Material Cache from the Properties Collections and also applying it to the Sprite. To apply at runtime the desired Collection Variation, just invoke UpdateMaterial() and put in as parameter the name of the Properties Collection Name. UpdateMaterial() can be invoked from many places, Scripting, Playmaker but also Animation Events.

The Solo Manager will probably your most used setup and is most important in conjunction with Animation Events.

Manager Host

The Manager Host works in pair with the Controller component, the idea behind this setup is to use it in a scenario where you like to separate the holding and applying of the Material Properties. You must give it an Reference name so that a Controller can find it. Again, the Manager just holds the Materials and can be attached to any GameObject - though due to a restriction, you can currently only use the Manager on an Gameobject with a Sprite Renderer component.

Consider the example where you spawn regularly Sprites(eg. Enemies) from a parent Gameobject. With the Manager in place, you could write a Script where you modify at runtime dynamically some properties on the Material Cache. This way, all child's or just any other Gameobject that holds a Controller with the corresponding Reference Id will match the changes of the Manager. A clean separation on modifying and applying Material properties.

Controller

The Controller must be attached to the actual Sprite you like to apply the Properties Collection to. You either plug in a Manager Host manually or search it at runtime by the Reference Id. Just like with the Solo Manager, you just invoke UpdateMaterial() and supply the name of the Properties Collection to apply the Material to the Sprite.

scripting/propertiescollection.txt · Last modified: 2015/12/10 23:28 by admin

Page Tools