- Home /
How to animate properties stored in arrays?
I created a script that has an array of Rects and i want to animate them in the Animation window.
Something like
public class Hitbox : MonoBehaviour
{
public Rect[] rect;
}
I have another script that draws the Hitbox on the SceneView, the thing is that Unity doesn't seem to support arrays in the Animation window when i try to add a new curve, the only property that is shown to me is the Enabled property, is there any way to solve this?
I'd recommend adding all your Rects as a single Rect and not as an array. rect1, rect2, etc.
Answer by paulordbm · Mar 24, 2014 at 08:20 PM
You could make a Rect-like class extend Monobehaviour
and add multiple copies of it to your GameObject
as needed. Each copy will show up at the Animation window. In the script you had the array of Rect
s, populate it with GetComponents()
and now you should be cool =)