- Home /
Create animation clip without "using UnityEditor"
Hi . In my 2D game I create the animations for many characters from their atlases using this code in my script . But I can't use UnityEditor in Build so I must find another way to do it . So far I haven't found a way . Please help !
using UnityEditor;
void createRunAnim(){
EditorCurveBinding curveBinding = new EditorCurveBinding();
curveBinding.type = typeof(SpriteRenderer);
curveBinding.path = "";
curveBinding.propertyName = "m_Sprite";
ObjectReferenceKeyframe[] runFrames = new ObjectReferenceKeyframe[6];
for(int i=3 ; i<= 8; i++){
runFrames[i-3] = new ObjectReferenceKeyframe();
runFrames[i-3].value = animalArray[i];
runFrames[i-3].time = (i-3);
}
AnimationUtility.SetObjectReferenceCurve(run,curveBinding,runFrames);
}
this script along with others like this are creating the animation clips depending on which character is selected .
Answer by fafase · Oct 11, 2014 at 02:27 PM
But you are creating the animation at runtime? If you are just creating them in editor and then using them, just save them at some point and create a reference to the animation to be used in game.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to keep an animation attached to gameobject 0 Answers
How to Play an Animation in Unity 4.5.3? 1 Answer
How can i animate my Object? (bones available) 1 Answer
UnityScript auto-format? 0 Answers