public List <BoneAnimConfig> ReadAnimConfig(string path)
    {
        List <BoneAnimConfig> list = new List <BoneAnimConfig>();
        string str = File.ReadAllText(path);

        string[][] array;
        GetAnimConfig(str, out array);

        for (int i = 0; i < array.Length; i++)
        {
            BoneAnimConfig AnimConfig = new BoneAnimConfig();
            AnimConfig.BoneName = array[i][0];
            mBoneInfo mBoneInfo = null;
            int       index     = 0;
            for (int j = 1; j < array[i].Length; j++)
            {
                switch (index)
                {
                case 0: mBoneInfo = new mBoneInfo(); break;

                case 1:
                    float.TryParse(array[i][j], out mBoneInfo.vctPos.x); break;

                case 2:
                    float.TryParse(array[i][j], out mBoneInfo.vctPos.y); break;

                case 3:
                    float.TryParse(array[i][j], out mBoneInfo.vctPos.z); break;

                case 4:
                    float.TryParse(array[i][j], out mBoneInfo.vctRot.x); break;

                case 5:
                    float.TryParse(array[i][j], out mBoneInfo.vctRot.y); break;

                case 6:
                    float.TryParse(array[i][j], out mBoneInfo.vctRot.z); break;

                case 7:
                    float.TryParse(array[i][j], out mBoneInfo.vctScl.x); break;

                case 8:
                    float.TryParse(array[i][j], out mBoneInfo.vctScl.y); break;

                case 9:
                    float.TryParse(array[i][j], out mBoneInfo.vctScl.z);
                    AnimConfig.BoneAimLis.Add(mBoneInfo);
                    index = -1;
                    break;

                default:
                    break;
                }
                index++;
            }
            list.Add(AnimConfig);
        }
        return(list);
    }
 //Anim-Key
 public mBoneInfo AddBoneAnimKey(int Animindex)
 {
     if (AnimConfig.Count > Animindex)
     {
         mBoneInfo BoneAnimKeyConfig = new mBoneInfo();
         BoneAnimKeyConfig.trfBone = AnimConfig[Animindex].Bonetransform;
         AnimConfig[Animindex].BoneAimLis.Add(BoneAnimKeyConfig);
         return(BoneAnimKeyConfig);
     }
     return(null);
 }
예제 #3
0
    void DrawAnim(int index)
    {
        if (index < 0 || index >= mCustomEditor.AnimConfig.Count)
        {
            return;
        }
        GUILayout.Space(5);
        Transform          BoneTransform     = mCustomEditor.AnimConfig[index].Bonetransform;
        SerializedObject   _serializedObject = new SerializedObject(mCustomEditor);
        SerializedProperty listIterator      = _serializedObject.FindProperty("AnimConfig");

        EditorGUI.BeginChangeCheck();

        GUILayout.BeginHorizontal();
        mCustomEditor.AnimConfig[index].Bonetransform = EditorGUILayout.ObjectField(mCustomEditor.AnimConfig[index].Bonetransform, typeof(Transform)) as Transform;
        if (GUILayout.Button("Remove"))
        {
            EditorApplication.Beep();

            //// 可以很方便的显示一个包含特定按钮的对话框,例如是否同意删除
            if (EditorUtility.DisplayDialog("Really?", "Do you really want to remove the state '" + mCustomEditor.AnimConfig[index].Bonetransform + "'?", "Yes", "No") == true)
            {
                Undo.RecordObject(mCustomEditor, "Delete State");
                mCustomEditor.AnimConfig.RemoveAt(index);
                EditorUtility.SetDirty(mCustomEditor);
            }
        }
        if (BoneTransform)
        {
            if (GUILayout.Button("添加Key", GUILayout.Width(200)))
            {
                mBoneInfo BoneInfo = mCustomEditor.AddBoneAnimKey(index);
                if (BoneInfo != null)
                {
                    BoneInfo.vctPos = BoneTransform.localPosition;
                    BoneInfo.vctRot = BoneTransform.localEulerAngles;
                    BoneInfo.vctScl = BoneTransform.localScale;
                }
            }
        }
        GUILayout.EndHorizontal();

        SerializedProperty ControBoneLis = listIterator.GetArrayElementAtIndex(index).FindPropertyRelative("BoneAimLis");

        EditorGUILayout.PropertyField(ControBoneLis, true);

        if (EditorGUI.EndChangeCheck())
        {
            _serializedObject.ApplyModifiedProperties();
        }
    }
 void SetBoneAnimKey(int Animindex, int index)
 {
     if (AnimConfig.Count > Animindex)
     {
         if (AnimConfig[Animindex].Bonetransform == null)
         {
             return;
         }
         if (AnimConfig[Animindex].BoneAimLis.Count <= index)
         {
             return;
         }
         mBoneInfo BoneAnimKeyConfig = AnimConfig[Animindex].BoneAimLis[index];
         BoneAnimKeyConfig.vctPos = BoneAnimKeyConfig.trfBone.localPosition;
         BoneAnimKeyConfig.vctRot = BoneAnimKeyConfig.trfBone.localEulerAngles;
         BoneAnimKeyConfig.vctScl = BoneAnimKeyConfig.trfBone.localScale;
     }
 }
예제 #5
0
 public void LoadInfo(BoneAnimConfig[] boneAnimConfig)
 {
     if (boneAnimConfig == null)
     {
         return;
     }
     dictInfo.Clear();
     for (int i = 0; i < boneAnimConfig.Length; i++)
     {
         List <mAnmKeyInfo> list = new List <mAnmKeyInfo>();
         for (int j = 0; j < boneAnimConfig[i].BoneAimLis.Count; j++)
         {
             mBoneInfo   mBoneInfo   = boneAnimConfig[i].BoneAimLis[j];
             mAnmKeyInfo mAnmKeyInfo = new mAnmKeyInfo();
             mAnmKeyInfo.Set(j, mBoneInfo.vctPos, mBoneInfo.vctRot, mBoneInfo.vctScl);
             list.Add(mAnmKeyInfo);
         }
         dictInfo[boneAnimConfig[i].BoneName] = list;
         Debug.Log("s");
     }
 }
예제 #6
0
    private bool GetDstBoneInfo(Transform trfBone, List <string> boneNames)
    {
        for (int i = 0; i < boneNames.Count; i++)
        {
            string bonename = boneNames[i];
            if (dictDstBoneInfo.ContainsKey(bonename))
            {
                continue;
            }

            GameObject gameObject = trfBone.FindLoop(bonename);
            if ((UnityEngine.Object)null != (UnityEngine.Object)gameObject)
            {
                mBoneInfo boneInfo = new mBoneInfo();
                boneInfo.trfBone          = gameObject.transform;
                boneInfo.vctPos           = gameObject.transform.localPosition;
                boneInfo.vctRot           = gameObject.transform.localEulerAngles;
                boneInfo.vctScl           = gameObject.transform.localScale;
                dictDstBoneInfo[bonename] = boneInfo;
            }
        }
        return(true);
    }
예제 #7
0
    //改变滑杆值
    public bool ChangeValue(int category, float value)
    {
        Debug.Log(category + " " + value);
        if (anmKeyInfo == null)
        {
            return(false);
        }
        if (!dictCategory.ContainsKey(category))
        {
            return(false);
        }
        int    count = dictCategory[category].Count;
        string empty = string.Empty;

        for (int i = 0; i < count; i++)
        {
            List <mCategoryInfo> list     = dictCategory[category];
            mBoneInfo            boneInfo = null;
            empty = list[i].bonename;
            if (dictDstBoneInfo.TryGetValue(empty, out boneInfo))
            {
                Vector3[] array = new Vector3[3];
                for (int j = 0; j < 3; j++)
                {
                    array[j] = Vector3.zero;
                }
                bool[] array2 = new bool[3];
                for (int k = 0; k < 3; k++)
                {
                    array2[k] = list[i].getflag[k];
                }
                anmKeyInfo.GetInfo(empty, value, ref array, array2);
                if (list[i].use[0][0])
                {
                    boneInfo.vctPos.x = array[0].x;
                }
                if (list[i].use[0][1])
                {
                    boneInfo.vctPos.y = array[0].y;
                }
                if (list[i].use[0][2])
                {
                    boneInfo.vctPos.z = array[0].z;
                }
                if (list[i].use[1][0])
                {
                    boneInfo.vctRot.x = array[1].x;
                }
                if (list[i].use[1][1])
                {
                    boneInfo.vctRot.y = array[1].y;
                }
                if (list[i].use[1][2])
                {
                    boneInfo.vctRot.z = array[1].z;
                }
                if (list[i].use[2][0])
                {
                    boneInfo.vctScl.x = array[2].x;
                }
                if (list[i].use[2][1])
                {
                    boneInfo.vctScl.y = array[2].y;
                }
                if (list[i].use[2][2])
                {
                    boneInfo.vctScl.z = array[2].z;
                }
            }
        }
        IsChange = true;
        return(true);
    }