Hi! Im watching the Animation Asset Api tutorial, from Unity5 tutorials, where explain how to make a Animator Controler automaticly with the Animation Helper. But in the Window menu of Unity 5 it doesn't exist. There is no Animation Helper nowhere. Somebody knows where it is?
You have to create that "AnimationHelper.cs" editor script first, into Editor folder, then it should appear to that menu given in the MenuItem line of that script
In the Project panel: Create new folder called Editor/ In the Project panel:Create new C# script, name it "AnimationHelper" and move it into that Editor/ folder Copy (write) the code from the video into that "AnimationHelper" script Then it should work as shown in the video
#if UNITY_EDITOR using UnityEditor; using UnityEditor.Animations; using UnityEngine; public class AnimationHelper : EditorWindow { public GameObject target; public AnimationClip idleAnim; public AnimationClip walkAnim; public AnimationClip runAnim; [MenuItem ("Window/Animator Helper")] static void OpenWindow () { //Get existing open window or if none, make a new one: GetWindow<AnimationHelper>(); } void OnGUI() { target = EditorGUILayout.ObjectField("Target Object", target, typeof(GameObject), true) as GameObject; idleAnim = EditorGUILayout.ObjectField("Idle", idleAnim, typeof(AnimationClip), false) as AnimationClip; walkAnim = EditorGUILayout.ObjectField("Walk", walkAnim, typeof(AnimationClip), false) as AnimationClip; runAnim = EditorGUILayout.ObjectField("Run", idleAnim, typeof(AnimationClip), false) as AnimationClip; if (GUILayout.Button("Create")) { if (target == null) { Debug.LogError ("No target for animator controller set."); return; } Create(); } } void Create () { AnimatorController controller = AnimatorController.CreateAnimatorControllerAtPath("Assets/" + target.name + ".controller"); // Adds a float parameter called Speed controller.AddParameter("Speed", AnimatorControllerParameterType.Float); //Add states AnimatorState idleState = controller.layers[0].stateMachine.AddState("Idle"); idleState.motion = idleAnim; //Blend tree creation BlendTree blendTree; AnimatorState moveState = controller.CreateBlendTreeInController("Move", out blendTree); //BlendTree setup blendTree.blendType = BlendTreeType.Simple1D; blendTree.blendParameter = "Speed"; blendTree.AddChild(walkAnim); blendTree.AddChild(runAnim); AnimatorStateTransition LeaveIdle = idleState.AddTransition(moveState); AnimatorStateTransition leaveMove = moveState.AddTransition(idleState); LeaveIdle.AddCondition(AnimatorConditionMode.Greater, 0.01f, "Speed"); leaveMove.AddCondition(AnimatorConditionMode.Less, 0.01f, "Speed"); target.GetComponent<Animator>().runtimeAnimatorController = controller; } } #endif Copy and paste the above into a c# file
hello everyone. I rewrite all the whole code. I don't know why the animator helper window wont work, I putted idle animation and run animation is putting itself automatically and I can't to change run animation. someone can tell me what is wrong? I have unity 5.
Unbelievable. We have to drop the code into Unity ourselves?? I did, after having to spend a lot of time parsing the code since the comment lines plank out everything and I don't know these functions. But nevertheless, after a lot of work I shouldn't have to do I got a clean compile. And of course it didn't work. The menu didn't pop up. No console error messages. Nothing. Unbelievable. Is there anything that could be done.
@LINKENN if you copy and paste the above code you get that error. to fix it go into void OnGUI() and find this line: runAnim = EditorGUILayout.ObjectField("Run", idleAnim, typeof(AnimationClip), false) as AnimationClip; then simply delete idleAnim and type runAnim, so you get that line: runAnim = EditorGUILayout.ObjectField("Run", runAnim, typeof(AnimationClip), false) as AnimationClip; worked for me. regards. p.s. i just realized i'am a bit late so sorry that noone helped you when you needed it...