- Home /
Animation (Legacy) SetCurve() to target GameObject active state
Hey there !
I'm trying to add through editor scripting a bunch of curve to an animation based on a existing game object in my project.
This screenshot is an example of what I'm trying to achieve. Just have reference of some gameobjects in my animation where I can toggle the activeSelf parameter in the timeline.
I managed to understand how to add a curve with SetCurve() of the clip but all the examples use floats and I just want to animate if the object is visible or not (boolean).
I tried something like
c.SetCurve(targetToAdd.name, typeof(GameObject), "IsActive", AnimationCurve.Linear(0,1,2,3));
But all it does is add a broken reference based on float instead of bool.
I'm guessing because of the last parameter I give that is a Linear animation curve based on floats.
What should I write in the SetCurve() to have a boolean reference ?
Many thanks !
Answer by ABerlemont · Jun 16, 2014 at 12:42 PM
The answer was "m_IsActive"
c.SetCurve(targetToAdd.name, typeof(GameObject), "m_IsActive", AnimationCurve.Linear(0f,1f,1f,1f));
I'm curious to know if there is a page where you have a list of those parameter strings somewhere ?
Got the answer from this unity wiki post where you can find more tools to work with curves :)