//Control-Bone
 public BoneControlConfig AddNewBone(int ControlIndex)
 {
     if (ControConfig.Count > ControlIndex)
     {
         BoneControlConfig boneControlConfig = new BoneControlConfig();
         ControConfig[ControlIndex].ControBoneLis.Add(boneControlConfig);
         return(boneControlConfig);
     }
     return(null);
 }
Example #2
0
    private bool LoadCategoryInfoList()
    {
        for (int i = 0; i < ControConfig.Length; i++)
        {
            List <mCategoryInfo> list = new List <mCategoryInfo>();
            for (int j = 0; j < ControConfig[i].ControBoneLis.Count; j++)
            {
                BoneControlConfig boneControlConfig = ControConfig[i].ControBoneLis[j];
                mCategoryInfo     categoryInfo      = new mCategoryInfo();
                categoryInfo.Initialize();
                categoryInfo.bonename = boneControlConfig.BoneName;

                categoryInfo.use[0][0] = (boneControlConfig.ControAble[0] && true);
                categoryInfo.use[0][1] = (boneControlConfig.ControAble[1] && true);
                categoryInfo.use[0][2] = (boneControlConfig.ControAble[2] && true);
                if (categoryInfo.use[0][0] || categoryInfo.use[0][1] || categoryInfo.use[0][2])
                {
                    categoryInfo.getflag[0] = true;
                }
                categoryInfo.use[1][0] = (boneControlConfig.ControAble[3] && true);
                categoryInfo.use[1][1] = (boneControlConfig.ControAble[4] && true);
                categoryInfo.use[1][2] = (boneControlConfig.ControAble[5] && true);
                if (categoryInfo.use[1][0] || categoryInfo.use[1][1] || categoryInfo.use[1][2])
                {
                    categoryInfo.getflag[1] = true;
                }
                categoryInfo.use[2][0] = (boneControlConfig.ControAble[6] && true);
                categoryInfo.use[2][1] = (boneControlConfig.ControAble[7] && true);
                categoryInfo.use[2][2] = (boneControlConfig.ControAble[8] && true);
                if (categoryInfo.use[2][0] || categoryInfo.use[2][1] || categoryInfo.use[2][2])
                {
                    categoryInfo.getflag[2] = true;
                }
                list.Add(categoryInfo);

                if (!DstBoneNameList.Contains(boneControlConfig.BoneName))
                {
                    DstBoneNameList.Add(boneControlConfig.BoneName);
                }
            }

            if (!dictCategory.ContainsKey(i))
            {
                dictCategory.Add(i, list);
            }
            else
            {
                dictCategory[i] = list;
            }
        }
        return(true);
    }
    //Read
    public List <ControConfig> ReadControlConfig(string path)
    {
        List <ControConfig> list = new List <ControConfig>();
        string str = File.ReadAllText(path);

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

        string       ControName   = "";
        ControConfig controConfig = null;
        int          length1      = array.GetLength(0);

        for (int i = 0; i < length1; i++)
        {
            string controName = array[i, 0];
            if (controName != ControName)
            {
                if (controConfig != null)
                {
                    list.Add(controConfig);
                }

                controConfig            = new ControConfig();
                controConfig.ControName = controName;
                ControName = controName;
            }
            BoneControlConfig boneControlConfig = new BoneControlConfig();
            boneControlConfig.BoneName      = array[i, 1];
            boneControlConfig.ControAble[0] = array[i, 2] == "1";
            boneControlConfig.ControAble[1] = array[i, 3] == "1";
            boneControlConfig.ControAble[2] = array[i, 4] == "1";
            boneControlConfig.ControAble[3] = array[i, 5] == "1";
            boneControlConfig.ControAble[4] = array[i, 6] == "1";
            boneControlConfig.ControAble[5] = array[i, 7] == "1";
            boneControlConfig.ControAble[6] = array[i, 8] == "1";
            boneControlConfig.ControAble[7] = array[i, 9] == "1";
            boneControlConfig.ControAble[8] = array[i, 10] == "1";
            controConfig.ControBoneLis.Add(boneControlConfig);

            if (i == length1 - 1)
            {
                list.Add(controConfig);
            }
        }
        return(list);
    }
Example #4
0
    void DrawControl(int index)
    {
        if (index < 0 || index >= mCustomEditor.ControConfig.Count)
        {
            return;
        }
        GUILayout.Space(5);
        SerializedObject   _serializedObject = new SerializedObject(mCustomEditor);
        SerializedProperty listIterator      = _serializedObject.FindProperty("ControConfig");

        GUILayout.BeginHorizontal();
        {
            //GUILayout.Label("Name", EditorStyles.label, GUILayout.Width(50));

            EditorGUI.BeginChangeCheck();

            string newName = GUILayout.TextField(mCustomEditor.ControConfig[index].ControName, GUILayout.Width(120));

            if (EditorGUI.EndChangeCheck())
            {
                //Create an Undo/Redo step for this modification
                Undo.RecordObject(mCustomEditor, "Modify State");

                mCustomEditor.ControConfig[index].ControName = newName;

                // 如果我们直接修改属性,而没有通过serializedObject,那么Unity并不会保存这些数据,Unity只会保存那些标识为dirty的属性
                EditorUtility.SetDirty(mCustomEditor);
            }

            if (GUILayout.Button("Remove"))
            {
                EditorApplication.Beep();

                //// 可以很方便的显示一个包含特定按钮的对话框,例如是否同意删除
                if (EditorUtility.DisplayDialog("Really?", "Do you really want to remove the state '" + mCustomEditor.ControConfig[index].ControName + "'?", "Yes", "No") == true)
                {
                    Undo.RecordObject(mCustomEditor, "Delete State");
                    mCustomEditor.ControConfig.RemoveAt(index);
                    EditorUtility.SetDirty(mCustomEditor);
                }
            }
            if (GUILayout.Button("添加骨骼", GUILayout.Width(200)))
            {
                if (BoneTransform == null)
                {
                    return;
                }

                BoneControlConfig boneControlConfig = new BoneControlConfig();
                boneControlConfig.Bonetransform = BoneTransform;
                boneControlConfig.BoneName      = BoneTransform.name;
                for (int i = 0; i < boneControlConfig.ControAble.Length; i++)
                {
                    boneControlConfig.ControAble[i] = BoneTransformAble[i];
                }
                mCustomEditor.ControConfig[index].ControBoneLis.Add(boneControlConfig);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            SerializedProperty ControBoneLis = listIterator.GetArrayElementAtIndex(index).FindPropertyRelative("ControBoneLis");
            EditorGUILayout.PropertyField(ControBoneLis, true);
            if (EditorGUI.EndChangeCheck())
            {
                _serializedObject.ApplyModifiedProperties();
            }
            GUILayout.EndHorizontal();
        }
    }