Inheritance: Object
    static void Motion_apparentSpeed(JSVCall vc)
    {
        UnityEngine.Motion _this = (UnityEngine.Motion)vc.csObj;
        var result = _this.apparentSpeed;

        JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
    }
// fields

// properties
    static void Motion_averageDuration(JSVCall vc)
    {
        UnityEngine.Motion _this = (UnityEngine.Motion)vc.csObj;
        var result = _this.averageDuration;

        JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
    }
    static void Motion_isHumanMotion(JSVCall vc)
    {
        UnityEngine.Motion _this = (UnityEngine.Motion)vc.csObj;
        var result = _this.isHumanMotion;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
Exemplo n.º 4
0
 private static GameObject CalculatePreviewGameObject(UnityEngine.Animator selectedAnimator, Motion motion, ModelImporterAnimationType animationType)
 {
     AnimationClip firstAnimationClipFromMotion = GetFirstAnimationClipFromMotion(motion);
     GameObject preview = AvatarPreviewSelection.GetPreview(animationType);
     if (IsValidPreviewGameObject(preview, ModelImporterAnimationType.None))
     {
         return preview;
     }
     if ((selectedAnimator != null) && IsValidPreviewGameObject(selectedAnimator.gameObject, animationType))
     {
         return selectedAnimator.gameObject;
     }
     preview = FindBestFittingRenderableGameObjectFromModelAsset(firstAnimationClipFromMotion, animationType);
     if (preview != null)
     {
         return preview;
     }
     if (animationType == ModelImporterAnimationType.Human)
     {
         return GetHumanoidFallback();
     }
     if (animationType == ModelImporterAnimationType.Generic)
     {
         return GetGenericAnimationFallback();
     }
     return null;
 }
    static void Motion_averageSpeed(JSVCall vc)
    {
        UnityEngine.Motion _this = (UnityEngine.Motion)vc.csObj;
        var result = _this.averageSpeed;

        JSApi.setVector3S((int)JSApi.SetType.Rval, result);
    }
Exemplo n.º 6
0
 static public int get_isHumanMotion(IntPtr l)
 {
     try {
         UnityEngine.Motion self = (UnityEngine.Motion)checkSelf(l);
         pushValue(l, self.isHumanMotion);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 7
0
 static public int get_apparentSpeed(IntPtr l)
 {
     try {
         UnityEngine.Motion self = (UnityEngine.Motion)checkSelf(l);
         pushValue(l, self.apparentSpeed);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 8
0
 static public int get_averageAngularSpeed(IntPtr l)
 {
     try {
         UnityEngine.Motion self = (UnityEngine.Motion)checkSelf(l);
         pushValue(l, self.averageAngularSpeed);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 9
0
 static public int get_averageAngularSpeed(IntPtr l)
 {
     try {
         UnityEngine.Motion self = (UnityEngine.Motion)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.averageAngularSpeed);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 10
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Motion o;
         o = new UnityEngine.Motion();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 11
0
 static public int get_legacy(IntPtr l)
 {
     try {
         UnityEngine.Motion self = (UnityEngine.Motion)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.legacy);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 12
0
 static public int get_legacy(IntPtr l)
 {
     try {
         UnityEngine.Motion self = (UnityEngine.Motion)checkSelf(l);
         pushValue(l, self.legacy);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.Motion o;
			o=new UnityEngine.Motion();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Exemplo n.º 14
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Motion o;
         o = new UnityEngine.Motion();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 15
0
        public static MotionType GetMotionType(UnityEngine.Motion motion)
        {
            var blendTree = motion as BlendTree;

            if (blendTree != null)
            {
                return(blendTree.blendType == BlendTreeType.Simple1D ? MotionType.BlendTree1D : MotionType.BlendTree2DSimpleDirectionnal);
            }
            else
            {
                return(MotionType.Clip);
            }
        }
Exemplo n.º 16
0
 public void ChangeMode(Mode mode)
 {
     switch (mode)
     {
         case Mode.Air:
             currentMotion = airRootMotion;
             break;
         case Mode.Ground:
             currentMotion = groundRootMotion;
             break;
     }
     currentMode = mode;
 }
Exemplo n.º 17
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.Motion o;
         o=new UnityEngine.Motion();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Exemplo n.º 18
0
 internal void AddChild(Motion motion, Vector2 position, float threshold)
 {
     Undo.RecordObject(this, "Added BlendTree Child");
     ChildMotion[] children = this.children;
     ChildMotion item = new ChildMotion {
         timeScale = 1f,
         motion = motion,
         position = position,
         threshold = threshold,
         directBlendParameter = "Blend"
     };
     ArrayUtility.Add<ChildMotion>(ref children, item);
     this.children = children;
 }
Exemplo n.º 19
0
 static public int ValidateIfRetargetable(IntPtr l)
 {
     try {
         UnityEngine.Motion self = (UnityEngine.Motion)checkSelf(l);
         System.Boolean     a1;
         checkType(l, 2, out a1);
         var ret = self.ValidateIfRetargetable(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// Generates the code to recreate the specified motion.
        /// </summary>
        /// <param name="motion">The motion to generate the code of.</param>
        /// <param name="motionSet">The list of motions which have been already generated.</param>
        /// <param name="generatedCode">The final generated code.</param>
        private static void GenerateMotion(UnityEngine.Motion motion, HashSet <UnityEngine.Motion> motionSet, StringBuilder generatedCode)
        {
            if (motionSet.Contains(motion))
            {
                return;
            }
            motionSet.Add(motion);

            // Store the GUID so the path can change and not affect the generated animator controller.
            var uniqueMotionName     = UniqueName(motion);
            var uniqueMotionNamePath = uniqueMotionName + "Path";

            generatedCode.AppendLine("\t\t\tvar " + uniqueMotionNamePath + " = AssetDatabase.GUIDToAssetPath(\"" +
                                     AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(motion as AnimationClip)) + "\"); ");
            generatedCode.AppendLine("\t\t\tvar " + uniqueMotionName + " = AnimatorBuilder.GetAnimationClip(" + uniqueMotionNamePath + ", \"" + motion.name + "\");");
        }
Exemplo n.º 21
0
    static int get_averageAngularSpeed(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Motion obj = (UnityEngine.Motion)o;
            float ret = obj.averageAngularSpeed;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index averageAngularSpeed on a nil value" : e.Message));
        }
    }
Exemplo n.º 22
0
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.Motion motion = (UnityEngine.Motion)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "name":
                    motion.name = reader.ReadProperty <System.String>();
                    break;

                case "hideFlags":
                    motion.hideFlags = reader.ReadProperty <UnityEngine.HideFlags>();
                    break;
                }
            }
        }
Exemplo n.º 23
0
    static int get_isHumanMotion(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Motion obj = (UnityEngine.Motion)o;
            bool ret = obj.isHumanMotion;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index isHumanMotion on a nil value" : e.Message));
        }
    }
Exemplo n.º 24
0
 public void SetOverrideMotion(AnimatorState state, Motion motion)
 {
     StateMotionPair pair;
     if (this.m_Motions == null)
     {
         this.m_Motions = new StateMotionPair[0];
     }
     for (int i = 0; i < this.m_Motions.Length; i++)
     {
         if (this.m_Motions[i].m_State == state)
         {
             this.m_Motions[i].m_Motion = motion;
             return;
         }
     }
     pair.m_State = state;
     pair.m_Motion = motion;
     ArrayUtility.Add<StateMotionPair>(ref this.m_Motions, pair);
 }
Exemplo n.º 25
0
        public static BlobAssetReference <Clip> Convert(UnityEngine.Motion motion)
        {
            var animationClip = motion as AnimationClip;

//            var blendTree = motion as BlendTree;
//
//            if (blendTree != null)
//                return Convert(blendTree);
//            else if( animationClip != null)
            if (animationClip != null)
            {
                var clip = ClipBuilder.AnimationClipToDenseClip(animationClip);
                return(clip);
            }
            else
            {
                throw new System.ArgumentException($"Selected Motion type is not supported.");
            }
        }
Exemplo n.º 26
0
    static int _CreateUnityEngine_Motion(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                UnityEngine.Motion obj = new UnityEngine.Motion();
                ToLua.Push(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Motion.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 27
0
 private void CreateStateMachine()
 {
     if ((this.m_Animator != null) && (this.m_Controller == null))
     {
         this.m_Controller = new AnimatorController();
         this.m_Controller.pushUndo = false;
         this.m_Controller.AddLayer("node");
         this.m_StateMachine = this.m_Controller.layers[0].stateMachine;
         this.m_StateMachine.pushUndo = false;
         this.CreateParameters();
         this.m_State = this.m_StateMachine.AddState("node", new Vector3());
         this.m_State.pushUndo = false;
         this.m_State.motion = this.motion;
         this.m_State.hideFlags = HideFlags.DontSave;
         this.m_Controller.hideFlags = HideFlags.DontSave;
         this.m_StateMachine.hideFlags = HideFlags.DontSave;
         AnimatorController.SetAnimatorController(this.m_Animator, this.m_Controller);
         this.m_Animator.Update(0f);
         this.m_Controller.OnAnimatorControllerDirty = (Action) Delegate.Combine(this.m_Controller.OnAnimatorControllerDirty, new Action(this, (IntPtr) this.ControllerDirty));
         this.m_ControllerIsDirty = false;
     }
 }
Exemplo n.º 28
0
        /// <summary>
        /// コンボ攻撃などを制御
        /// </summary>
        public PlayerAttackFlow(Animator animator)
        {
            this.animator = animator;
            groundRootMotion = new Motion();
            Motion attack1 = new Motion("GroundAttack1", 1.3f, 1, InputName.Attack, 0.5f);
            Motion attack2 = new Motion("GroundAttack2", 1.3f, 2, InputName.Attack, 0.5f);
            Motion attack3 = new Motion("GroundAttack3", 1.3f, 3, InputName.Attack, 0.5f);
            // コンボ攻撃を追加
            groundRootMotion.AddNextMotion(attack1);
            attack1.AddNextMotion(attack2);
            attack2.AddNextMotion(attack3);

            airRootMotion = new Motion();
            attack1 = new Motion("AirAttack1", 1.3f, 1, InputName.Attack, 0.5f);
            attack2 = new Motion("AirAttack2", 1.3f, 2, InputName.Attack, 0.5f);
            attack3 = new Motion("AirAttack3", 1.3f, 3, InputName.Attack, 0.5f);

            // コンボ攻撃を追加
            airRootMotion.AddNextMotion(attack1);
            attack1.AddNextMotion(attack2);
            attack2.AddNextMotion(attack3);

            currentMotion = groundRootMotion;
        }
Exemplo n.º 29
0
 public static ModelImporterAnimationType GetAnimationType(Motion motion)
 {
     AnimationClip firstAnimationClipFromMotion = GetFirstAnimationClipFromMotion(motion);
     if (firstAnimationClipFromMotion == null)
     {
         return ModelImporterAnimationType.None;
     }
     if (firstAnimationClipFromMotion.legacy)
     {
         return ModelImporterAnimationType.Legacy;
     }
     if (firstAnimationClipFromMotion.humanMotion)
     {
         return ModelImporterAnimationType.Human;
     }
     return ModelImporterAnimationType.Generic;
 }
Exemplo n.º 30
0
				public MotionList(BinaryReader bin)
				{
					this.motion_count = bin.ReadUInt32();
					this.motion = new Dictionary<string, List<Motion>>();
					
					// 一度バッファに貯めてソートする
					Motion[] buf = new Motion[this.motion_count];
					for (int i = 0; i < this.motion_count; i++)
						buf[i] = new Motion(bin);
					Array.Sort(buf);
					
					// モーションの数だけnewされないよね?
					for (int i = 0; i < this.motion_count; i++) {
						try { this.motion.Add(buf[i].bone_name, new List<Motion>()); }
						catch {}
					}
					
					// dictionaryにどんどん登録
					for (int i = 0; i < this.motion_count; i++) 
						this.motion[buf[i].bone_name].Add(buf[i]);
				}
 private void CreateController()
 {
   if (!((UnityEngine.Object) this.m_Controller == (UnityEngine.Object) null) || this.m_AvatarPreview == null || (!((UnityEngine.Object) this.m_AvatarPreview.Animator != (UnityEngine.Object) null) || !((UnityEngine.Object) this.m_RefTransition != (UnityEngine.Object) null)))
     return;
   this.m_LayerIndex = 0;
   this.m_Controller = new AnimatorController();
   this.m_Controller.pushUndo = false;
   this.m_Controller.hideFlags = HideFlags.HideAndDontSave;
   this.m_Controller.AddLayer("preview");
   bool flag = true;
   if ((UnityEngine.Object) this.m_LayerMask != (UnityEngine.Object) null)
   {
     for (AvatarMaskBodyPart index = AvatarMaskBodyPart.Root; index < AvatarMaskBodyPart.LastBodyPart && flag; ++index)
     {
       if (!this.m_LayerMask.GetHumanoidBodyPartActive(index))
         flag = false;
     }
     if (!flag)
     {
       this.m_Controller.AddLayer("Additionnal");
       ++this.m_LayerIndex;
       AnimatorControllerLayer[] layers = this.m_Controller.layers;
       layers[this.m_LayerIndex].avatarMask = this.m_LayerMask;
       this.m_Controller.layers = layers;
     }
   }
   this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine;
   this.m_StateMachine.pushUndo = false;
   this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave;
   this.m_SrcMotion = this.m_RefSrcState.motion;
   this.m_DstMotion = this.m_RefDstState.motion;
   this.m_ParameterMinMax.Clear();
   if ((bool) ((UnityEngine.Object) this.m_SrcMotion) && this.m_SrcMotion is BlendTree)
   {
     BlendTree srcMotion = this.m_SrcMotion as BlendTree;
     for (int index = 0; index < srcMotion.recursiveBlendParameterCount; ++index)
     {
       string recursiveBlendParameter = srcMotion.GetRecursiveBlendParameter(index);
       if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1)
       {
         this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
         this.m_ParameterMinMax.Add(new Vector2(srcMotion.GetRecursiveBlendParameterMin(index), srcMotion.GetRecursiveBlendParameterMax(index)));
       }
     }
   }
   if ((bool) ((UnityEngine.Object) this.m_DstMotion) && this.m_DstMotion is BlendTree)
   {
     BlendTree dstMotion = this.m_DstMotion as BlendTree;
     for (int index1 = 0; index1 < dstMotion.recursiveBlendParameterCount; ++index1)
     {
       string recursiveBlendParameter = dstMotion.GetRecursiveBlendParameter(index1);
       int index2 = this.m_Controller.IndexOfParameter(recursiveBlendParameter);
       if (index2 == -1)
       {
         this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
         this.m_ParameterMinMax.Add(new Vector2(dstMotion.GetRecursiveBlendParameterMin(index1), dstMotion.GetRecursiveBlendParameterMax(index1)));
       }
       else
         this.m_ParameterMinMax[index2] = new Vector2(Mathf.Min(dstMotion.GetRecursiveBlendParameterMin(index1), this.m_ParameterMinMax[index2][0]), Mathf.Max(dstMotion.GetRecursiveBlendParameterMax(index1), this.m_ParameterMinMax[index2][1]));
     }
   }
   this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name);
   this.m_SrcState.pushUndo = false;
   this.m_SrcState.hideFlags = HideFlags.HideAndDontSave;
   this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name);
   this.m_DstState.pushUndo = false;
   this.m_DstState.hideFlags = HideFlags.HideAndDontSave;
   this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState);
   this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState);
   this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true);
   this.m_Transition.pushUndo = false;
   this.m_Transition.hideFlags = HideFlags.DontSave;
   this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition);
   this.DisableIKOnFeetIfNeeded();
   AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
   this.m_Controller.OnAnimatorControllerDirty += new System.Action(this.ControllerDirty);
 }
Exemplo n.º 32
0
        private static void SearchBlendTreeMotion(AnimatorController animator, Motion motion, AssetData assetData)
        {
            AddAttachedAsset(animator, motion, assetData, false);

            var blendTree = motion as BlendTree;

            if (!blendTree) return;
            int childCount = 0;

            if (isUnity41)
            {
                childCount = (int)blendTree.GetType().GetMethod("GetChildCount").Invoke(blendTree, new object[0]);
            }
            else
            {
                childCount = (int)blendTree.GetType().GetProperty("childCount").GetValue(blendTree, new object[0]);
            }
            for (var i = 0; i < childCount; i++)
            {
                SearchBlendTreeMotion(animator, blendTree.GetMotion(i), assetData);
            }
        }
Exemplo n.º 33
0
 private static AnimationClip GetFirstAnimationClipFromMotion(Motion motion)
 {
   AnimationClip animationClip = motion as AnimationClip;
   if ((bool) ((Object) animationClip))
     return animationClip;
   UnityEditor.Animations.BlendTree blendTree = motion as UnityEditor.Animations.BlendTree;
   if ((bool) ((Object) blendTree))
   {
     AnimationClip[] animationClipsFlattened = blendTree.GetAnimationClipsFlattened();
     if (animationClipsFlattened.Length > 0)
       return animationClipsFlattened[0];
   }
   return (AnimationClip) null;
 }
Exemplo n.º 34
0
 private void Init(Animator scenePreviewObject, Motion motion)
 {
     if (this.m_AvatarPreview == null)
     {
         this.m_AvatarPreview = new AvatarPreview(scenePreviewObject, motion);
         this.m_AvatarPreview.OnAvatarChangeFunc = new AvatarPreview.OnAvatarChange(this.OnPreviewAvatarChanged);
         this.m_AvatarPreview.ShowIKOnFeetButton = false;
     }
     if (this.m_Timeline == null)
     {
         this.m_Timeline = new Timeline();
         this.m_MustSampleMotions = true;
     }
     this.CreateController();
     if (this.m_ParameterInfoList == null)
     {
         this.CreateParameterInfoList();
     }
 }
Exemplo n.º 35
0
 public AvatarPreview(UnityEngine.Animator previewObjectInScene, Motion objectOnSameAsset)
 {
     this.InitInstance(previewObjectInScene, objectOnSameAsset);
 }
Exemplo n.º 36
0
 /// <summary>
 /// <para>Utility function to add a child motion to a blend trees.</para>
 /// </summary>
 /// <param name="motion">The motion to add as child.</param>
 /// <param name="position">The position of the child. When using 2D blend trees.</param>
 /// <param name="threshold">The threshold of the child. When using 1D blend trees.</param>
 public void AddChild(Motion motion)
 {
     this.AddChild(motion, Vector2.zero, 0f);
 }
Exemplo n.º 37
0
            /// <summary>
            /// モーション制御
            /// </summary>
            /// <returns>別のモーションへの遷移フラグ</returns>
            public bool MotionControl(out Motion newMotion, out int motionID)
            {
                foreach (Motion motion in nextMotions)
                {
                    if (Input.GetButtonDown(motion.nextInputName) &&
                        motionCount >= motionSeconds - inputReceptionSeconds) // 入力受付時間内なら
                    {
                        changeMotion = motion;
                    }
                }

                // 攻撃モーション後に次のモーションへ移行
                motionCount += Time.deltaTime;
                if (motionCount > motionSeconds)
                {
                    newMotion = changeMotion;
                    if (changeMotion == null)
                    {
                        motionID = 0;
                    }
                    else
                    {
                        motionID = changeMotion.motionID;
                    }

                    motionCount = 0.0f;
                    changeMotion = null;
                    return true;
                }

                newMotion = this;
                motionID = 0;
                return false;
            }
Exemplo n.º 38
0
 /// <summary>
 /// 次に遷移する攻撃モーションを設定
 /// </summary>
 public Motion AddNextMotion(Motion motion)
 {
     nextMotions.Add(motion);
     return motion;
 }
Exemplo n.º 39
0
        /// <summary>
        /// The custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            int i = 0;



            //////  RESTORE SAVED  //////
            //restore and delete clipboard


            mecanimNode = target as MecanimNode;

            if (mecanimNode != null)
            {
                Motion motion = null;



                //////////////////////////////////////////////////////////////
                ///                         PRESEVE RESTORE					//
                if (EditorApplication.isPlaying || EditorApplication.isPaused)
                {
                    if (GUILayout.Button("Preserve"))
                    {
                        serializedNode.ApplyModifiedProperties();

                        UnityVariable.SetDirty(mecanimNode.blendX);

                        UnityVariable.SetDirty(mecanimNode.blendY);
                        UnityVariable.SetDirty(mecanimNode.motionOverride);

//												if (variablesBindedToCurves != null) {
//														UnityVariable[] varArray = variablesBindedToCurves;
//
//														int varNumber = varArray.Length;
//														for (int varCurrent=0; varCurrent<varNumber; varCurrent++) {
//																varArray [varCurrent].OnBeforeSerialize ();
//
//														}
//												}


                        EditorUtilityEx.Clipboard.preserve(mecanimNode.instanceID, mecanimNode, mecanimNode.GetType().GetFields());
                    }
                }
                else
                {
                    if (EditorUtilityEx.Clipboard.HasBeenPreseved(mecanimNode.instanceID) && GUILayout.Button("Apply Playmode Changes"))
                    {
                        EditorUtilityEx.Clipboard.restore(mecanimNode.instanceID, mecanimNode);

                        animatorStateSerialized = null;
                        NodePropertyIterator iterator = serializedNode.GetIterator();



                        while (iterator.Next(true))
                        {
                            if (iterator.current.value is UnityVariable)
                            {
                                //Debug.Log("OnBeforeDeserialize:"+((UnityVariable)iterator.current.value).Value);
                                ((UnityVariable)iterator.current.value).OnAfterDeserialize();

                                //Debug.Log("OnAfterDeserialize:"+((UnityVariable)iterator.current.value).Value);
                            }
                            else if (iterator.current.value is UnityVariable[])
                            {
                                UnityVariable[] varArray  = (UnityVariable[])iterator.current.value;
                                int             varNumber = varArray.Length;
                                for (int varCurrent = 0; varCurrent < varNumber; varCurrent++)
                                {
                                    varArray [varCurrent].OnAfterDeserialize();
                                }
                            }


                            iterator.current.ValueChanged();

                            this.serializedNode.Update();

                            iterator.current.ApplyModifiedValue();
                        }
                    }
                }
                //////////////////////


                if (Event.current.type == EventType.Layout)
                {
                    this.serializedNode.Update();
                }



                DrawDefaultInspector();

//
//				if (EditorGUILayoutEx.ANIMATION_STYLES == null)
//					EditorGUILayoutEx.ANIMATION_STYLES = new EditorGUILayoutEx.AnimationStyles ();



                /////////////////////////////// ANIMATOR STATE /////////////////////////////////

                if (animatorStateSerialized == null)
                {
                    NodePropertyIterator iterator = this.serializedNode.GetIterator();
                    if (iterator.Find("animatorStateSelected"))
                    {
                        animatorStateSerialized = iterator.current;
                    }


                    if (iterator.Find("motionOverride"))
                    {
                        motionOverrideSerialized = iterator.current;
                    }
                }



                //////////  MOTION OVERRIDE HANDLING  //////////
                if (animatorStateSerialized.value != null)
                {
                    UnityVariable motionOverridVariable = (UnityVariable)motionOverrideSerialized.value;

                    //if there are no override use motion of selected AnimationState
                    //Debug.Log(((UnityEngine.Object)mecanimNode.motionOverride.Value).);
                    if (motionOverridVariable == null || motionOverridVariable.Value == null || motionOverridVariable.ValueType != typeof(AnimationClip))
                    {
                        motion = ((ws.winx.unity.AnimatorState)animatorStateSerialized.value).motion;
                    }
                    else                                                             //
                    {
                        motion = (Motion)motionOverridVariable.Value;
                    }



                    if (motionOverridVariable != null && motionOverridVariable.Value != null && ((ws.winx.unity.AnimatorState)animatorStateSerialized.value).motion == null)
                    {
                        Debug.LogError("Can't override state that doesn't contain motion");
                    }
                }
                ///////////////////////////////////////////////////

                if (GUILayout.Button("BindEditor") && motion != null)
                {
                    MecanimNodeEditorWindow.Show(mecanimNode.self, motion as AnimationClip, this.serializedNode, null);
                }

                /////////////   TIME CONTROL OF ANIMATION (SLIDER) /////////
                if (Application.isPlaying)
                {
                    if (animatorStateRuntimeControlEnabledSerialized == null)
                    {
                        NodePropertyIterator iterator = this.serializedNode.GetIterator();

                        if (iterator.Find("animationRunTimeControlEnabled"))
                        {
                            animatorStateRuntimeControlEnabledSerialized = iterator.current;
                        }

                        if (iterator.Find("animatorStateRunTimeControl"))
                        {
                            animatorStateRunTimeControlSerialized = iterator.current;
                        }
                    }



                    if (animatorStateRuntimeControlEnabledSerialized != null && animatorStateRunTimeControlSerialized != null && (bool)animatorStateRuntimeControlEnabledSerialized.value)
                    {
                        Rect timeControlRect = GUILayoutUtility.GetRect(Screen.width - 16f, 26f);
                        timeControlRect.xMin += 38f;
                        timeControlRect.xMax -= 70f;
                        animatorStateRunTimeControlSerialized.value = EditorGUILayoutEx.CustomHSlider(timeControlRect, (float)animatorStateRunTimeControlSerialized.value, 0f, 1f, EditorGUILayoutEx.ANIMATION_STYLES.timeScrubber);
                    }
                }
                ///////////////////////////////////////////////////////////////


                /////////// AVATAR Preview GUI ////////////


                if (!Application.isPlaying && motion != null)
                {
                    //This makes layout to work (Reserving space)
                    Rect avatarRect = GUILayoutUtility.GetRect(Screen.width - 16f, 200);
                    avatarRect.width -= 70f;
                    avatarRect.xMin  += 6f;


                    if (avatarPreview == null)
                    {
                        avatarPreview = new AvatarPreviewW(null, motion);
                    }
                    else
                    {
                        avatarPreview.SetPreviewMotion(motion);
                    }



                    EditorGUILayout.BeginHorizontal();



                    if (eventTimeValues != null && Event.current.type == EventType.Repaint)
                    {
                        //find first selected if exist
                        int eventTimeValueSelectedIndex = Array.IndexOf(eventTimeValuesSelected, true);



                        if (eventTimeValueSelectedIndex > -1)
                        {
                            avatarPreview.SetTimeAt(eventTimeValues [eventTimeValueSelectedIndex]);
                        }
                        else
                        {
                            //!!! changing
                            //avatarPreview.timeControl.startTime
                            // start/stop makes AvatarPreview to play from start to stop
                            // and the rest of animation isn't visible in Timeline so not good for selecting range
                            // but its not offer good usability of resized animation


                            if (avatarPreview.timeControl.playing)
                            {
                                //restrict animation into this range
                                if (avatarPreview.timeControl.normalizedTime < mecanimNode.range.rangeStart || avatarPreview.timeControl.normalizedTime > mecanimNode.range.rangeEnd)
                                {
                                    avatarPreview.timeControl.nextCurrentTime = avatarPreview.timeControl.startTime * (1f - mecanimNode.range.rangeStart) + avatarPreview.timeControl.stopTime * mecanimNode.range.rangeStart;
                                }
                            }
                            else
                            {
                                //set AvatarPreview animation time range depending of drag of range control handles
                                if (Math.Abs(mecanimNode.range.rangeStart - timeNormalizedStartPrev) > 0.01f)
                                {
                                    timeNormalizedStartPrev = mecanimNode.range.rangeStart;

                                    avatarPreview.SetTimeAt(timeNormalizedStartPrev);
                                }
                                else
                                if (Math.Abs(mecanimNode.range.rangeEnd - timeNormalizedEndPrev) > 0.01f)
                                {
                                    timeNormalizedEndPrev = mecanimNode.range.rangeEnd;
                                    avatarPreview.SetTimeAt(timeNormalizedEndPrev);
                                }
                            }
                        }
                    }



                    avatarPreview.timeControl.playbackSpeed = mecanimNode.speed;



                    avatarPreview.DoAvatarPreview(avatarRect, GUIStyle.none);



                    //Debug.Log(avatarPreview.timeControl.currentTime+" "+);
                    EditorGUILayout.EndHorizontal();



                    ////////// Events Timeline GUI //////////

                    if (!eventTimeLineInitalized)
                    {
                        //TODO calculate PopupRect

                        eventTimeLineValuePopUpRect = new Rect((Screen.width - 250) * 0.5f, (Screen.height - 150) * 0.5f, 250, 150);


                        //select the time values from nodes
                        //eventTimeValues = mecanimNode.children.Select ((val) => (float)((SendEventNormalized)val).timeNormalized.Value).ToArray ();


                        eventTimeValues = mecanimNode.children.Select((val) => (float)(((SendEventNormalizedNode)val).timeNormalized.serializedProperty as SerializedProperty).floatValue).ToArray();


                        eventDisplayNames       = mecanimNode.children.Select((val) => ((SendEventNormalizedNode)val).name).ToArray();
                        eventTimeValuesSelected = new bool[eventTimeValues.Length];

                        playButtonStyle = "TimeScrubberButton";

                        if (playButtonStyle != null)
                        {
                            playButtonSize = playButtonStyle.CalcSize(new GUIContent());
                        }

                        eventTimeLineInitalized = true;
                    }



                    Rect timeLineRect = GUILayoutUtility.GetRect(Screen.width - 16f, 50f);
                    //Rect timeLineRect = GUILayoutUtility.GetLastRect ();


                    Texture eventMarkerTexture = EditorGUILayoutEx.ANIMATION_STYLES.eventMarker.image;
                    timeLineRect.xMin += playButtonSize.x - eventMarkerTexture.width * 0.5f;
                    timeLineRect.xMax -= eventMarkerTexture.width * 0.5f;
                    //timeLineRect.height = EditorGUILayoutEx.eventMarkerTexture.height * 3 * 0.66f + playButtonSize.y;
                    timeLineRect.width -= 66f;
                    EditorGUILayoutEx.CustomTimeLine(ref timeLineRect, new GUIContent(eventMarkerTexture), ref eventTimeValues, ref eventTimeValuesPrev, ref eventDisplayNames, ref eventTimeValuesSelected, avatarPreview.timeControl.normalizedTime,
                                                     onMecanimEventAdd, onMecanimEventDelete, onMecanimEventClose, onMecanimEventEdit, onMecanimEventDragEnd
                                                     );

                    EditorGUILayout.LabelField("Events Timeline");

                    SendEventNormalizedNode ev;



                    //update time values
                    int eventTimeValuesNumber = mecanimNode.children.Length;
                    for (i = 0; i < eventTimeValuesNumber; i++)
                    {
                        ev = ((SendEventNormalizedNode)mecanimNode.children [i]);
                        //ev.timeNormalized.Value = eventTimeValues [i];
                        ev.timeNormalized.Value = eventTimeValues [i];

                        //if changes have been made in pop editor or SendEventNormailized inspector
                        if (ev.name != eventDisplayNames [i])
                        {
                            eventDisplayNames [i] = ((SendEventNormalizedNode)mecanimNode.children [i]).name;
                        }

                        EditorUtilityEx.ApplySerializedPropertyChangeTo(ev.timeNormalized);
                        //ev.timeNormalized.ApplyModifiedProperties ();
                    }



                    // Restore the indent level
                    //EditorGUI.indentLevel = indentLevel;

                    // Apply modified properties
                    this.serializedNode.ApplyModifiedProperties();
                }
            }
        }
Exemplo n.º 40
0
 private void CreateController()
 {
     if (((this.m_Controller == null) && (this.m_AvatarPreview != null)) && ((this.m_AvatarPreview.Animator != null) && (this.m_RefTransition != null)))
     {
         this.m_LayerIndex = 0;
         this.m_Controller = new AnimatorController();
         this.m_Controller.pushUndo = false;
         this.m_Controller.hideFlags = HideFlags.HideAndDontSave;
         this.m_Controller.AddLayer("preview");
         bool flag = true;
         if (this.m_LayerMask != null)
         {
             int humanoidBodyPartCount = this.m_LayerMask.humanoidBodyPartCount;
             for (int i = 0; (i < humanoidBodyPartCount) && flag; i++)
             {
                 if (!this.m_LayerMask.GetHumanoidBodyPartActive(i))
                 {
                     flag = false;
                 }
             }
             if (!flag)
             {
                 this.m_Controller.AddLayer("Additionnal");
                 this.m_LayerIndex++;
                 AnimatorControllerLayer[] layers = this.m_Controller.layers;
                 layers[this.m_LayerIndex].avatarMask = this.m_LayerMask;
                 this.m_Controller.layers = layers;
             }
         }
         this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine;
         this.m_StateMachine.pushUndo = false;
         this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave;
         this.m_SrcMotion = this.m_RefSrcState.motion;
         this.m_DstMotion = this.m_RefDstState.motion;
         this.m_ParameterMinMax.Clear();
         if ((this.m_SrcMotion != null) && (this.m_SrcMotion is BlendTree))
         {
             BlendTree srcMotion = this.m_SrcMotion as BlendTree;
             for (int j = 0; j < srcMotion.recursiveBlendParameterCount; j++)
             {
                 string recursiveBlendParameter = srcMotion.GetRecursiveBlendParameter(j);
                 if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1)
                 {
                     this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
                     this.m_ParameterMinMax.Add(new Vector2(srcMotion.GetRecursiveBlendParameterMin(j), srcMotion.GetRecursiveBlendParameterMax(j)));
                 }
             }
         }
         if ((this.m_DstMotion != null) && (this.m_DstMotion is BlendTree))
         {
             BlendTree dstMotion = this.m_DstMotion as BlendTree;
             for (int k = 0; k < dstMotion.recursiveBlendParameterCount; k++)
             {
                 string name = dstMotion.GetRecursiveBlendParameter(k);
                 int num5 = this.m_Controller.IndexOfParameter(name);
                 if (num5 == -1)
                 {
                     this.m_Controller.AddParameter(name, AnimatorControllerParameterType.Float);
                     this.m_ParameterMinMax.Add(new Vector2(dstMotion.GetRecursiveBlendParameterMin(k), dstMotion.GetRecursiveBlendParameterMax(k)));
                 }
                 else
                 {
                     Vector2 vector = this.m_ParameterMinMax[num5];
                     Vector2 vector2 = this.m_ParameterMinMax[num5];
                     this.m_ParameterMinMax[num5] = new Vector2(Mathf.Min(dstMotion.GetRecursiveBlendParameterMin(k), vector[0]), Mathf.Max(dstMotion.GetRecursiveBlendParameterMax(k), vector2[1]));
                 }
             }
         }
         this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name);
         this.m_SrcState.pushUndo = false;
         this.m_SrcState.hideFlags = HideFlags.HideAndDontSave;
         this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name);
         this.m_DstState.pushUndo = false;
         this.m_DstState.hideFlags = HideFlags.HideAndDontSave;
         this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState);
         this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState);
         this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true);
         this.m_Transition.pushUndo = false;
         this.m_Transition.hideFlags = HideFlags.DontSave;
         this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition);
         this.DisableIKOnFeetIfNeeded();
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
         this.m_Controller.OnAnimatorControllerDirty = (System.Action) Delegate.Combine(this.m_Controller.OnAnimatorControllerDirty, new System.Action(this.ControllerDirty));
     }
 }
Exemplo n.º 41
0
 private void SetMotion(AnimatorState state, int layerIndex, Motion motion)
 {
     AnimatorControllerLayer[] layers = this.m_Controller.layers;
     state.motion = motion;
     this.m_Controller.layers = layers;
 }
Exemplo n.º 42
0
 private static AnimationClip GetFirstAnimationClipFromMotion(Motion motion)
 {
     AnimationClip clip = motion as AnimationClip;
     if (clip != null)
     {
         return clip;
     }
     UnityEditor.Animations.BlendTree tree = motion as UnityEditor.Animations.BlendTree;
     if (tree != null)
     {
         AnimationClip[] animationClipsFlattened = tree.GetAnimationClipsFlattened();
         if (animationClipsFlattened.Length > 0)
         {
             return animationClipsFlattened[0];
         }
     }
     return null;
 }
Exemplo n.º 43
0
 private void InitInstance(UnityEngine.Animator scenePreviewObject, Motion motion)
 {
     this.m_SourcePreviewMotion = motion;
     this.m_SourceScenePreviewAnimator = scenePreviewObject;
     if (this.m_PreviewInstance == null)
     {
         GameObject go = CalculatePreviewGameObject(scenePreviewObject, motion, this.animationClipType);
         this.SetupBounds(go);
     }
     if (this.timeControl == null)
     {
         this.timeControl = new TimeControl();
     }
     if (this.m_ReferenceInstance == null)
     {
         GameObject original = (GameObject) EditorGUIUtility.Load("Avatar/dial_flat.prefab");
         this.m_ReferenceInstance = (GameObject) UnityEngine.Object.Instantiate(original, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_ReferenceInstance);
     }
     if (this.m_DirectionInstance == null)
     {
         GameObject obj4 = (GameObject) EditorGUIUtility.Load("Avatar/arrow.fbx");
         this.m_DirectionInstance = (GameObject) UnityEngine.Object.Instantiate(obj4, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_DirectionInstance);
     }
     if (this.m_PivotInstance == null)
     {
         GameObject obj5 = (GameObject) EditorGUIUtility.Load("Avatar/root.fbx");
         this.m_PivotInstance = (GameObject) UnityEngine.Object.Instantiate(obj5, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_PivotInstance);
     }
     if (this.m_RootInstance == null)
     {
         GameObject obj6 = (GameObject) EditorGUIUtility.Load("Avatar/root.fbx");
         this.m_RootInstance = (GameObject) UnityEngine.Object.Instantiate(obj6, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_RootInstance);
     }
     this.m_IKOnFeet = EditorPrefs.GetBool("AvatarpreviewShowIK", false);
     this.m_ShowReference = EditorPrefs.GetBool("AvatarpreviewShowReference", true);
     this.timeControl.playbackSpeed = EditorPrefs.GetFloat("AvatarpreviewSpeed", 1f);
     this.SetPreviewCharacterEnabled(false, false);
 }
Exemplo n.º 44
0
 /// <summary>
 /// <para>Utility function to add a child motion to a blend trees.</para>
 /// </summary>
 /// <param name="motion">The motion to add as child.</param>
 /// <param name="position">The position of the child. When using 2D blend trees.</param>
 /// <param name="threshold">The threshold of the child. When using 1D blend trees.</param>
 public void AddChild(Motion motion, Vector2 position)
 {
     this.AddChild(motion, position, 0f);
 }
Exemplo n.º 45
0
 public static ModelImporterAnimationType GetAnimationType(Motion motion)
 {
   AnimationClip animationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);
   if (!(bool) ((Object) animationClipFromMotion))
     return ModelImporterAnimationType.None;
   if (animationClipFromMotion.legacy)
     return ModelImporterAnimationType.Legacy;
   return animationClipFromMotion.humanMotion ? ModelImporterAnimationType.Human : ModelImporterAnimationType.Generic;
 }
Exemplo n.º 46
0
        private void UpdateMotion(Motion motion)
        {
            if (Event.current.type != EventType.Repaint) {
                                return;
                        }

                        //Debug.Log ("UpdateAvatarState");

                        if (this.Animator) {
            //								if (PrevIKOnFeet != IKOnFeet)
            //								{
            //									PrevIKOnFeet =IKOnFeet;
            //
            //									//save root pos and rot
            //									Vector3 rootPosition = this.Animator.rootPosition;
            //									Quaternion rootRotation = this.Animator.rootRotation;
            //
            //									ClearPreviewStateMachine();
            //									CreatePreviewStateMachine(motion);
            //
            //									this.Animator.Update(this.timeControl.currentTime);
            //									this.Animator.Update(0f);
            //
            //									//restore root pos and rot
            //									this.Animator.rootPosition = rootPosition;
            //									this.Animator.rootRotation = rootRotation;
            //								}

            //								this.timeControl.loop = true;
                                float timeAnimationLength = 1f;//1s
                                float timeNormalized = 0f;
            //
            //
                                if (this.Animator.layerCount > 0) {

                                        AnimatorStateInfo currentAnimatorStateInfo = this.Animator.GetCurrentAnimatorStateInfo (0);
                                        timeAnimationLength = currentAnimatorStateInfo.length;

                                        timeNormalized = currentAnimatorStateInfo.normalizedTime;
                                }

                                //this.timeControl.startTime = timeAnimationLength * _timeStartNormailized;
                                //this.timeControl.stopTime = timeAnimationLength * _timeStopNormalized;

                                //float timeAnimationLength=((AnimationClip)motion).length;

                                this.timeControl.startTime = timeAnimationLength * _timeStartNormailized;
                                this.timeControl.stopTime = timeAnimationLength * _timeStopNormalized;

                                this.timeControl.Update ();

                                //deltaTime is nextCurrentTime-currentTime
                                //is set my drag of red Timeline handle or manually thru SetTimeValue

                                float timeDelta = this.timeControl.deltaTime;

                                if (this.timeControl.playing) {
                                        if (!motion.isLooping) {
                                                if (timeNormalized >= 1f) {
                                                        timeDelta -= this.timeControl.stopTime - this.timeControl.startTime;//timeAnimationLength;
                                                } else {
                                                        if (timeNormalized < 0f) {
                                                                timeDelta += this.timeControl.stopTime - this.timeControl.startTime;// timeAnimationLength;
                                                        }
                                                }
                                        }
                                }

                                this.Animator.Update (timeDelta);
                        }
        }
Exemplo n.º 47
0
 /// <summary>
 /// <para>Utility function to add a child motion to a blend trees.</para>
 /// </summary>
 /// <param name="motion">The motion to add as child.</param>
 /// <param name="position">The position of the child. When using 2D blend trees.</param>
 /// <param name="threshold">The threshold of the child. When using 1D blend trees.</param>
 public void AddChild(Motion motion, float threshold)
 {
     this.AddChild(motion, Vector2.zero, threshold);
 }
Exemplo n.º 48
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.Motion motion = (UnityEngine.Motion)value;
     writer.WriteProperty("name", motion.name);
     writer.WriteProperty("hideFlags", motion.hideFlags);
 }
Exemplo n.º 49
0
		private static GameObject CalculatePreviewGameObject(Animator selectedAnimator, Motion motion, ModelImporterAnimationType animationType)
		{
			AnimationClip firstAnimationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);
			GameObject gameObject = AvatarPreviewSelection.GetPreview(animationType);
			if (AvatarPreview.IsValidPreviewGameObject(gameObject, ModelImporterAnimationType.None))
			{
				return gameObject;
			}
			if (selectedAnimator != null && AvatarPreview.IsValidPreviewGameObject(selectedAnimator.gameObject, animationType))
			{
				return selectedAnimator.gameObject;
			}
			gameObject = AvatarPreview.FindBestFittingRenderableGameObjectFromModelAsset(firstAnimationClipFromMotion, animationType);
			if (gameObject != null)
			{
				return gameObject;
			}
			if (animationType == ModelImporterAnimationType.Human)
			{
				return AvatarPreview.GetHumanoidFallback();
			}
			if (animationType == ModelImporterAnimationType.Generic)
			{
				return AvatarPreview.GetGenericAnimationFallback();
			}
			return null;
		}
Exemplo n.º 50
0
 private static GameObject CalculatePreviewGameObject(Animator selectedAnimator, Motion motion, ModelImporterAnimationType animationType)
 {
   AnimationClip animationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);
   GameObject preview = AvatarPreviewSelection.GetPreview(animationType);
   if (AvatarPreview.IsValidPreviewGameObject(preview, ModelImporterAnimationType.None))
     return preview;
   if ((Object) selectedAnimator != (Object) null && AvatarPreview.IsValidPreviewGameObject(selectedAnimator.gameObject, animationType))
     return selectedAnimator.gameObject;
   GameObject objectFromModelAsset = AvatarPreview.FindBestFittingRenderableGameObjectFromModelAsset((Object) animationClipFromMotion, animationType);
   if ((Object) objectFromModelAsset != (Object) null)
     return objectFromModelAsset;
   if (animationType == ModelImporterAnimationType.Human)
     return AvatarPreview.GetHumanoidFallback();
   if (animationType == ModelImporterAnimationType.Generic)
     return AvatarPreview.GetGenericAnimationFallback();
   return (GameObject) null;
 }
 /// <summary>
 ///   <para>Sets the override motion for the state on the given layer.</para>
 /// </summary>
 /// <param name="state">The state which we want to set the motion.</param>
 /// <param name="motion">The motion that will be set.</param>
 public void SetOverrideMotion(AnimatorState state, Motion motion)
 {
   if (this.m_Motions == null)
     this.m_Motions = new StateMotionPair[0];
   for (int index = 0; index < this.m_Motions.Length; ++index)
   {
     if ((Object) this.m_Motions[index].m_State == (Object) state)
     {
       this.m_Motions[index].m_Motion = motion;
       return;
     }
   }
   StateMotionPair stateMotionPair;
   stateMotionPair.m_State = state;
   stateMotionPair.m_Motion = motion;
   ArrayUtility.Add<StateMotionPair>(ref this.m_Motions, stateMotionPair);
 }
Exemplo n.º 52
0
        /// <summary>
        /// Creates the preview state machine.
        /// </summary>
        /// <param name="motion">Motion.</param>
        private void CreatePreviewStateMachine(Motion motion)
        {
            if (this.Animator == null)
                                return;

                        //Debug.Log ("CreateStateMachine");

                        if (_previewAnimatorController == null) {
                                _previewAnimatorController = new UnityEditor.Animations.AnimatorController ();
                                _previewAnimatorController.AddLayer ("previewLayer");
                                _previewAnimatorController.hideFlags = HideFlags.DontSave;

                                _previewStateMachine = _previewAnimatorController.layers [0].stateMachine;
                                CreateParameters (motion);

                                _previewState = _previewStateMachine.AddState ("previewState");

                                _previewState.motion = motion;
                                _previewState.iKOnFeet = this.IKOnFeet;
                                _previewState.hideFlags = HideFlags.DontSave;

                                UnityEditor.Animations.AnimatorController.SetAnimatorController (this.Animator, _previewAnimatorController);
                                //Debug.Log ("Setting avatarPreview.Animator " + this.Animator.name + " to temp controller");
                        }

            //			if (AnimatorController.GetEffectiveAnimatorController (this.Animator) != this._previewAnimatorController) {
            //				AnimatorController.SetAnimatorController (this.Animator, this._previewAnimatorController);
            //
            //				Debug.Log ("Getting Effective Animator and set avatarPreview.Animator " + this.Animator.name + " to temp controller");
            //			}
        }