private static UnityEditor.Animations.AnimatorState AddStateTransition(UnityEditor.Animations.AnimatorController animatorController, string path, UnityEditor.Animations.AnimatorControllerLayer layer)
    {
        ////根据动画文件读取它的AnimationClip对象
        AnimationClip newClip = null;

        if (File.Exists(path))
        {
            newClip = AssetDatabase.LoadAssetAtPath(path, typeof(AnimationClip)) as AnimationClip;
        }
        string[] sL    = Path.GetFileName(path).Split(".".ToCharArray());
        string   aName = sL[0];

        UnityEngine.AnimatorControllerParameter p = new UnityEngine.AnimatorControllerParameter();
        p.type        = UnityEngine.AnimatorControllerParameterType.Bool;
        p.name        = aName;
        p.defaultBool = false;
        animatorController.AddParameter(p);


        ////取出动画名子 添加到state里面
        UnityEditor.Animations.AnimatorState state = layer.stateMachine.AddState(aName);
        if (newClip != null)
        {
            state.motion = newClip;
        }

        return(state);

        //把state添加在layer里面
        //UnityEditor.Animations.AnimatorStateTransition ts = sm.AddAnyStateTransition(state);
    }
        /// <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.AnimatorControllerParameter animatorControllerParameter = (UnityEngine.AnimatorControllerParameter)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "type":
                    animatorControllerParameter.type = reader.ReadProperty <UnityEngine.AnimatorControllerParameterType> ();
                    break;

                case "defaultFloat":
                    animatorControllerParameter.defaultFloat = reader.ReadProperty <System.Single> ();
                    break;

                case "defaultInt":
                    animatorControllerParameter.defaultInt = reader.ReadProperty <System.Int32> ();
                    break;

                case "defaultBool":
                    animatorControllerParameter.defaultBool = reader.ReadProperty <System.Boolean> ();
                    break;
                }
            }
        }
Exemple #3
0
 public void AddParameter(UnityEngine.AnimatorControllerParameter paramater)
 {
     this.undoHandler.DoUndo(this, "Parameter added");
     UnityEngine.AnimatorControllerParameter[] parameters = this.parameters;
     ArrayUtility.Add <UnityEngine.AnimatorControllerParameter>(ref parameters, paramater);
     this.parameters = parameters;
 }
 static public int get_type(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.type);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
        private void DoParameterList()
        {
            int num = this.m_ParameterList.index;

            this.m_ParameterList.list = this.activeTree;
            if (num >= this.activeTree.Length)
            {
                num = this.activeTree.Length - 1;
            }
            this.m_ParameterList.index     = num;
            this.m_ParameterList.draggable = (!this.m_Host.liveLink && this.activeTree == this.m_Tree);
            string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;

            EditorGUI.kFloatFieldFormatString = "f1";
            this.m_ScrollPosition             = GUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]);
            EditorGUI.BeginChangeCheck();
            this.m_ParameterList.DoLayoutList();
            if (EditorGUI.EndChangeCheck() && !this.m_Host.liveLink)
            {
                ParameterControllerView.Element[]         tree  = this.m_Tree;
                UnityEngine.AnimatorControllerParameter[] array = new UnityEngine.AnimatorControllerParameter[tree.Length];
                for (int i = 0; i < tree.Length; i++)
                {
                    array[i] = tree[i].m_Parameter;
                }
                this.m_Host.animatorController.parameters = array;
            }
            GUILayout.EndScrollView();
            EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
        }
        private ParameterControllerView.Element CreateElement(UnityEngine.AnimatorControllerParameter parameter)
        {
            UnityEngine.AnimatorControllerParameterType type = parameter.type;
            UnityEngine.AnimatorControllerParameterType animatorControllerParameterType = type;
            switch (animatorControllerParameterType)
            {
            case UnityEngine.AnimatorControllerParameterType.Float:
                return(new ParameterControllerView.FloatElement(parameter, this));

            case (UnityEngine.AnimatorControllerParameterType) 2:
IL_21:
                if (animatorControllerParameterType != UnityEngine.AnimatorControllerParameterType.Trigger)
                {
                    return(null);
                }
                return(new ParameterControllerView.TriggerElement(parameter, this));

            case UnityEngine.AnimatorControllerParameterType.Int:
                return(new ParameterControllerView.IntElement(parameter, this));

            case UnityEngine.AnimatorControllerParameterType.Bool:
                return(new ParameterControllerView.BoolElement(parameter, this));
            }
            goto IL_21;
        }
Exemple #7
0
 public void RemoveParameter(UnityEngine.AnimatorControllerParameter parameter)
 {
     this.undoHandler.DoUndo(this, "Parameter removed");
     UnityEngine.AnimatorControllerParameter[] parameters = this.parameters;
     ArrayUtility.Remove <UnityEngine.AnimatorControllerParameter>(ref parameters, parameter);
     this.parameters = parameters;
 }
// fields

// properties
    static void AnimatorControllerParameter_nameHash(JSVCall vc)
    {
        UnityEngine.AnimatorControllerParameter _this = (UnityEngine.AnimatorControllerParameter)vc.csObj;
        var result = _this.nameHash;

        JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
    }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.AnimatorControllerParameter o;
         o = new UnityEngine.AnimatorControllerParameter();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemple #10
0
 public void AddParameter(string name, UnityEngine.AnimatorControllerParameterType type)
 {
     UnityEngine.AnimatorControllerParameter paramater = new UnityEngine.AnimatorControllerParameter {
         name = this.MakeUniqueParameterName(name),
         type = type
     };
     this.AddParameter(paramater);
 }
 /// <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.AnimatorControllerParameter animatorControllerParameter = (UnityEngine.AnimatorControllerParameter)value;
     writer.WriteProperty("type", animatorControllerParameter.type);
     writer.WriteProperty("defaultFloat", animatorControllerParameter.defaultFloat);
     writer.WriteProperty("defaultInt", animatorControllerParameter.defaultInt);
     writer.WriteProperty("defaultBool", animatorControllerParameter.defaultBool);
 }
 static void AddConstant(StringBuilder sb, ref int indent, Parameter parameter)
 {
     NewLine(sb, indent);
     sb.Append("const int ");
     AddConstantName(sb, parameter);
     sb.Append(" = ");
     sb.Append(parameter.nameHash);
     sb.AppendLine(";");
 }
 static public int get_defaultInt(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         pushValue(l, self.defaultInt);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int get_defaultFloat(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.defaultFloat);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_type(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         pushEnum(l, (int)self.type);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.AnimatorControllerParameter o;
			o=new UnityEngine.AnimatorControllerParameter();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 static public int get_type(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.type);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter o;
         o = new UnityEngine.AnimatorControllerParameter();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter o;
         o=new UnityEngine.AnimatorControllerParameter();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter o;
         o = new UnityEngine.AnimatorControllerParameter();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int set_type(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter     self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         UnityEngine.AnimatorControllerParameterType v;
         checkEnum(l, 2, out v);
         self.type = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 private GUIContent[] BuildParamList(AnimatorControllerParameter[] paramList, string propVal, out int selectedIndex)
 {
     selectedIndex = -1;
     GUIContent[] paramsGUI = new GUIContent[paramList.Length+1];
     for (int i = 0; i < paramList.Length; i++)
     {
         AnimatorControllerParameter param = paramList[i];
         paramsGUI[i] = new GUIContent(param.name);
         if (param.name.Equals(propVal))
             selectedIndex = i;
     }
     paramsGUI[paramList.Length] = new GUIContent("<None>");
     return paramsGUI;
 }
 static public int set_type(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter     self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         UnityEngine.AnimatorControllerParameterType v;
         checkEnum(l, 2, out v);
         self.type = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int set_defaultFloat(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.defaultFloat = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_defaultFloat(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.defaultFloat = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static void AnimatorControllerParameter_type(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.AnimatorControllerParameter _this = (UnityEngine.AnimatorControllerParameter)vc.csObj;
         var result = _this.type;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.AnimatorControllerParameterType arg0  = (UnityEngine.AnimatorControllerParameterType)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.AnimatorControllerParameter     _this = (UnityEngine.AnimatorControllerParameter)vc.csObj;
         _this.type = arg0;
     }
 }
 static void AnimatorControllerParameter_defaultFloat(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.AnimatorControllerParameter _this = (UnityEngine.AnimatorControllerParameter)vc.csObj;
         var result = _this.defaultFloat;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.AnimatorControllerParameter _this = (UnityEngine.AnimatorControllerParameter)vc.csObj;
         _this.defaultFloat = arg0;
     }
 }
 static void AnimatorControllerParameter_defaultBool(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.AnimatorControllerParameter _this = (UnityEngine.AnimatorControllerParameter)vc.csObj;
         var result = _this.defaultBool;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean arg0 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.AnimatorControllerParameter _this = (UnityEngine.AnimatorControllerParameter)vc.csObj;
         _this.defaultBool = arg0;
     }
 }
 static new public int Equals(IntPtr l)
 {
     try {
         UnityEngine.AnimatorControllerParameter self = (UnityEngine.AnimatorControllerParameter)checkSelf(l);
         System.Object a1;
         checkType(l, 2, out a1);
         var ret = self.Equals(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public AnimatorControllerParameter(AnimatorController ac, UnityEngine.AnimatorControllerParameter p)
        {
            this.parent = ac;
            this.asset  = p;
            this.name   = p.name;
            //this.nameHash = p.nameHash;
            this.type = (int)(p.type == AnimatorControllerParameterType.Int ? AnimatorControllerParameterType.Float : p.type);
            switch (p.type)
            {
            case AnimatorControllerParameterType.Float: this.defaultValue = p.defaultFloat; break;

            case AnimatorControllerParameterType.Int: this.defaultValue = p.defaultInt; break;

            default: this.defaultValue = p.defaultBool; break;
            }
        }
Exemple #31
0
    public static void CreateAnimatorParameter(UnityEditor.Animations.AnimatorController obj)
    {
        UnityEngine.AnimatorControllerParameter[] aCParameters = new UnityEngine.AnimatorControllerParameter[8];
        aCParameters[0] = new UnityEngine.AnimatorControllerParameter
        {
            name = "Hit_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };
        aCParameters[1] = new UnityEngine.AnimatorControllerParameter
        {
            name = "Run_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };
        aCParameters[2] = new UnityEngine.AnimatorControllerParameter
        {
            name = "Idel_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };
        aCParameters[3] = new UnityEngine.AnimatorControllerParameter
        {
            name = "Walk_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };
        aCParameters[4] = new UnityEngine.AnimatorControllerParameter
        {
            name = "LAtk_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };
        aCParameters[5] = new UnityEngine.AnimatorControllerParameter
        {
            name = "RAtk_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };
        aCParameters[6] = new UnityEngine.AnimatorControllerParameter
        {
            name = "AAtk_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };
        aCParameters[7] = new UnityEngine.AnimatorControllerParameter
        {
            name = "Die_1",
            type = UnityEngine.AnimatorControllerParameterType.Trigger,
        };

        obj.parameters = aCParameters;
    }
 private void OnReorderParameter(ReorderableList reorderablelist)
 {
     ParameterControllerView.Element[] array = new ParameterControllerView.Element[reorderablelist.list.Count];
     reorderablelist.list.CopyTo(array, 0);
     UnityEngine.AnimatorControllerParameter[] array2 = new UnityEngine.AnimatorControllerParameter[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         if (array[i] == null || array[i].m_Parameter == null)
         {
             return;
         }
         array2[i] = array[i].m_Parameter;
     }
     Undo.RegisterCompleteObjectUndo(this.m_Host.animatorController, "Parameter reordering");
     this.m_Host.animatorController.parameters = array2;
     this.RebuildList();
 }
Exemple #33
0
        private Element CreateElement(UnityEngine.AnimatorControllerParameter parameter)
        {
            switch (parameter.type)
            {
            case UnityEngine.AnimatorControllerParameterType.Float:
                return(new FloatElement(parameter, this));

            case UnityEngine.AnimatorControllerParameterType.Int:
                return(new IntElement(parameter, this));

            case UnityEngine.AnimatorControllerParameterType.Bool:
                return(new BoolElement(parameter, this));

            case UnityEngine.AnimatorControllerParameterType.Trigger:
                return(new TriggerElement(parameter, this));
            }
            return(null);
        }
 private void DoParameterList()
 {
     int index = this.m_ParameterList.index;
     this.m_ParameterList.list = this.activeTree;
     if (index >= this.activeTree.Length)
     {
         index = this.activeTree.Length - 1;
     }
     this.m_ParameterList.index = index;
     this.m_ParameterList.draggable = !this.m_Host.liveLink && (this.activeTree == this.m_Tree);
     string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
     EditorGUI.kFloatFieldFormatString = "f1";
     this.m_ScrollPosition = GUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]);
     EditorGUI.BeginChangeCheck();
     this.m_ParameterList.DoLayoutList();
     if (EditorGUI.EndChangeCheck() && !this.m_Host.liveLink)
     {
         Element[] tree = this.m_Tree;
         UnityEngine.AnimatorControllerParameter[] parameterArray = new UnityEngine.AnimatorControllerParameter[tree.Length];
         for (int i = 0; i < tree.Length; i++)
         {
             parameterArray[i] = tree[i].m_Parameter;
         }
         this.m_Host.animatorController.parameters = parameterArray;
     }
     GUILayout.EndScrollView();
     EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
 }
    static int _CreateAnimatorControllerParameter(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            AnimatorControllerParameter obj = new AnimatorControllerParameter();
            LuaScriptMgr.PushObject(L, obj);
            return 1;
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: AnimatorControllerParameter.New");
        }

        return 0;
    }
Exemple #36
0
 public void clear()
 {
     m_animatorControllerParameter = null;
 }
 private void OnReorderParameter(ReorderableList reorderablelist)
 {
     Element[] array = new Element[reorderablelist.list.Count];
     reorderablelist.list.CopyTo(array, 0);
     UnityEngine.AnimatorControllerParameter[] parameterArray = new UnityEngine.AnimatorControllerParameter[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         if ((array[i] == null) || (array[i].m_Parameter == null))
         {
             return;
         }
         parameterArray[i] = array[i].m_Parameter;
     }
     Undo.RegisterCompleteObjectUndo(this.m_Host.animatorController, "Parameter reordering");
     this.m_Host.animatorController.parameters = parameterArray;
     this.RebuildList();
 }
 public Element(UnityEngine.AnimatorControllerParameter parameter, ParameterControllerView host)
 {
     this.m_Host = host;
     this.m_Parameter = parameter;
 }
 private void CreateParameters(AnimatorController controller, List<AnimationClip> animationClips, string prefix = "")
 {
     foreach (var clip in animationClips)
     {
         var newParam = new AnimatorControllerParameter();
         newParam.type = AnimatorControllerParameterType.Bool;
         newParam.defaultBool = false;
         newParam.name = prefix + clip.name;
         controller.AddParameter(prefix + clip.name, AnimatorControllerParameterType.Bool);
     }
 }