示例#1
0
        void OnGUI()
        {
            GUIStyle boxStyle = new GUIStyle("box");

            var width  = position.size.x - boxStyle.border.horizontal;
            var height = position.size.y - boxStyle.border.vertical;

            var innerBoxWidth  = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal);
            var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical);

            MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action>
            {
                {
                    "读取", loadWeapon
                },
                {
                    "保存", saveWeapon
                },
                {
                    "制作当前预制体", CreatCurrentPrefab
                }
            });


            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height));

            MyGUIExtend.Instance.Foldout("WeaponEditor", "路径信息", (() =>
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(weaponDataFile);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath);
                if (MyGUI.Button("载入表格"))
                {
                    EditorTools.AnalyzeExcelToDic(excelPath, dic =>
                    {
                        EquipType equipType = (EquipType)Convert.ToInt32(dic["EquipType"]);
                        bool newWeaponData = true;
                        switch (equipType)
                        {
                        case EquipType.Lswd:
                            break;

                        case EquipType.Shield:
                            break;

                        case EquipType.Swd:
                            break;

                        case EquipType.Sswd:
                            break;

                        case EquipType.Saxe:
                            break;

                        case EquipType.Blunt:
                            break;

                        case EquipType.Katana:
                            break;

                        case EquipType.Bow:
                            break;

                        case EquipType.Spear:
                            break;

                        default:
                            newWeaponData = false;
                            break;
                        }
                        if (newWeaponData)
                        {
                            WeaponData NewWeaponData = new WeaponData();
                            foreach (var item in dic)
                            {
                                switch (item.Key)
                                {
                                case "id":
                                    NewWeaponData.id = Convert.ToString(item.Value);
                                    break;

                                case "IconName":
                                    NewWeaponData.icon = Convert.ToString(item.Value);
                                    break;

                                case "name":
                                    NewWeaponData.name = Convert.ToString(item.Value);
                                    break;

                                case "Lv":
                                    NewWeaponData.level = Convert.ToInt32(item.Value);
                                    break;

                                case "desc":
                                    NewWeaponData.desc = Convert.ToString(item.Value);
                                    break;

                                case "Hp":
                                    NewWeaponData.attrData.hpMax = Convert.ToSingle(item.Value);
                                    break;

                                case "defence":
                                    NewWeaponData.attrData.def = Convert.ToSingle(item.Value);
                                    break;

                                case "ATK":
                                    NewWeaponData.attrData.atk = Convert.ToSingle(item.Value);
                                    break;

                                case "speed":
                                    NewWeaponData.attrData.atkSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "Critical":
                                    NewWeaponData.attrData.criticalRate = Convert.ToSingle(item.Value);
                                    break;

                                case "CriticalDamage":
                                    NewWeaponData.attrData.criticalDamage = Convert.ToSingle(item.Value);
                                    break;

                                case "move":
                                    NewWeaponData.attrData.moveSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "EquipType":
                                    NewWeaponData.equipType = equipType;
                                    break;
                                }
                            }

                            int index = weaponDataList.FindIndex((data) => data.id == NewWeaponData.id);

                            if (index >= 0)
                            {
                                string icon = weaponDataList[index].icon;
                                weaponDataList.RemoveAt(index);
                                NewWeaponData.icon = icon;
                            }

                            weaponDataList.Add(NewWeaponData);
                        }
                    });
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(prefabPath);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(skeletonDataAssetPath, typeof(Spine.Unity.SkeletonDataAsset));
                skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField(new GUIContent("SkeletonDataAsstet"), skeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset), true);
                skeletonDataAssetPath = AssetDatabase.GetAssetPath(skeletonDataAsset);
                EditorGUILayout.EndHorizontal();
            }));



            // 编辑区域 add by TangJian 2017/11/15 16:28:19
            EditorGUILayout.BeginHorizontal();

            // // 列表框 add by TangJian 2017/11/15 16:27:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos);

            for (int i = weaponDataList.Count - 1; i >= 0; i--)
            {
                var item = weaponDataList[i];
                EditorGUILayout.BeginHorizontal();

                int Index = MyGUIExtend.Instance.ListSingleButton("WeaponEditor", item.id, i, (() => { currWeaponData = item; }));

                MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action>
                {
                    {
                        "复制", (() =>
                        {
                            var weaponData = Tools.Json2Obj <WeaponData>(Tools.Obj2Json(weaponDataList[Index], true));
                            weaponDataList.Add(weaponData);
                        })
                    },
                    {
                        "删除", (() => { weaponDataList.RemoveAt(Index); })
                    }
                });
                EditorGUILayout.EndHorizontal();
            }

            if (MyGUI.Button("+"))
            {
                weaponDataList.Add(new WeaponData());
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            // 编辑框 add by TangJian 2017/11/15 16:28:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos);
            if (currWeaponData != null)
            {
                MyGUI.ItemDataField(currWeaponData, skeletonDataAssetPath);
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
示例#2
0
        void OnGUI()
        {
            GUIStyle boxStyle = new GUIStyle("box");

            var width  = position.size.x - boxStyle.border.horizontal;
            var height = position.size.y - boxStyle.border.vertical;

            var innerBoxWidth  = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal);
            var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical);

            MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action>
            {
                {
                    "读取", LoadData
                },
                {
                    "保存", SaveData
                },
                {
                    "制作预制体", CreatePrefabs
                }
            });

            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height));


            MyGUIExtend.Instance.Foldout("DcorationEditor", "路径信息", (() =>
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(decorationDataFile);
                excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath);
                if (MyGUI.Button("载入Excel"))
                {
                    EditorTools.AnalyzeExcelToDic(excelPath, dic =>
                    {
                        EquipType equipType = (EquipType)Convert.ToInt32(dic["EquipType"]);
                        switch (equipType)
                        {
                        case EquipType.Decoration:
                        case EquipType.Glove:
                        case EquipType.Shoe:
                        case EquipType.Ring:
                            DecorationData newDecorationData = new DecorationData();

                            foreach (var item in dic)
                            {
                                switch (item.Key)
                                {
                                case "id":
                                    newDecorationData.id = Convert.ToString(item.Value);
                                    break;

                                case "IconName":
                                    newDecorationData.icon = Convert.ToString(item.Value);
                                    break;

                                case "name":
                                    newDecorationData.name = Convert.ToString(item.Value);
                                    break;

                                case "Lv":
                                    newDecorationData.level = Convert.ToInt32(item.Value);
                                    break;

                                case "desc":
                                    newDecorationData.desc = Convert.ToString(item.Value);
                                    break;

                                case "Hp":
                                    newDecorationData.attrData.hpMax = Convert.ToSingle(item.Value);
                                    break;

                                case "defence":
                                    newDecorationData.attrData.def = Convert.ToSingle(item.Value);
                                    break;

                                case "ATK":
                                    newDecorationData.attrData.atk = Convert.ToSingle(item.Value);
                                    break;

                                case "speed":
                                    newDecorationData.attrData.atkSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "Critical":
                                    newDecorationData.attrData.criticalRate = Convert.ToSingle(item.Value);
                                    break;

                                case "CriticalDamage":
                                    newDecorationData.attrData.criticalDamage = Convert.ToSingle(item.Value);
                                    break;

                                case "move":
                                    newDecorationData.attrData.moveSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "EquipType":
                                    newDecorationData.equipType = equipType;
                                    break;
                                }
                            }

                            int index = decorationDataList.FindIndex((data) =>
                            {
                                return(data.id == newDecorationData.id);
                            });

                            if (index >= 0)
                            {
                                decorationDataList.RemoveAt(index);
                            }

                            decorationDataList.Add(newDecorationData);

                            break;
                        }
                    });
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(prefabPath);
                EditorGUILayout.EndHorizontal();
            }));



            // 编辑区域 add by TangJian 2017/11/15 16:28:19
            EditorGUILayout.BeginHorizontal();

            // // 列表框 add by TangJian 2017/11/15 16:27:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos);

            for (int i = decorationDataList.Count - 1; i >= 0; i--)
            {
                var item = decorationDataList[i];

                EditorGUILayout.BeginHorizontal();
                int Index = MyGUIExtend.Instance.ListSingleButton("DocrationEditor", item.id, i, (() => { currDecorationData = item; }));

                MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action>
                {
                    {
                        "删除", (() => { decorationDataList.RemoveAt(Index); })
                    },
                    {
                        "复制", () =>
                        {
                            var decorationData = Tools.Json2Obj <DecorationData>(Tools.Obj2Json(decorationDataList[Index], true));
                            decorationDataList.Add(decorationData);
                        }
                    }
                });
                EditorGUILayout.EndHorizontal();
            }

            if (MyGUI.Button("+"))
            {
                decorationDataList.Add(new DecorationData());
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            // 编辑框 add by TangJian 2017/11/15 16:28:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos);
            if (currDecorationData != null)
            {
                MyGUI.ItemDataField(currDecorationData);
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }