Exemplo n.º 1
0
        public static void Open(tian.PlacementConfig placementConfig)
        {
            BoxTextureEditorWindow window = (BoxTextureEditorWindow)EditorWindow.GetWindow(typeof(BoxTextureEditorWindow));

            window.title = "UV Editor";

            window.placementConfig = placementConfig;

            window.Show();
            if (placementConfig.randerChoice == tian.RanderChoice.Anim)
            {
                Selection.activeObject       = (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(placementConfig.SkeletonDataAssetpath, typeof(Spine.Unity.SkeletonDataAsset));
                window.skeletonPreviewEditor = UnityEditor.Editor.CreateEditor(Selection.activeObject, typeof(Spine.Unity.Editor.SkeletonPreviewEditor)) as Spine.Unity.Editor.SkeletonPreviewEditor;
            }

            window.material = new Material(Shader.Find("Sprites/Default"));
        }
Exemplo n.º 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>
            {
                {
                    "读取", LoadRole
                },
                {
                    "All", () =>
                    {
                        currtagname = "";
                        showIndexList.Clear();
                        for (int ix = 0; ix < _placementConfigList.Count; ix++)
                        {
                            showIndexList.Add(ix);
                        }
                    }
                },
                {
                    "仅保存数据", saveData
                },
                {
                    "保存数据仅生成当前选中预制体", () =>
                    {
                        saveData();
                        Createprefab();
                    }
                }
            });


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

            MyGUIExtend.Instance.Foldout("BoxEditor", "路径信息", () =>
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(_roleDataFile);

                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(_prefabPath);

                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                _scalefloat = MyGUI.FloatFieldWithTitle("图片整体缩放大小", _scalefloat);
                EditorGUILayout.EndHorizontal();
            });

            // 编辑区域 add by TangJian 2017/11/15 16:28:19
            EditorGUILayout.BeginHorizontal();
            //一级列表
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width((innerBoxWidth / 2) * (1f / 3f) - 5f), GUILayout.ExpandHeight(true));
            onelistViewPos = EditorGUILayout.BeginScrollView(onelistViewPos);
            for (int e = taglist.Count - 1; e >= 0; e--)
            {
                var tag = taglist[e];
                EditorGUILayout.BeginHorizontal();

                int Index = MyGUIExtend.Instance.ListSingleButton("BoxTag", taglist[e], e, (() =>
                {
                    currtagname = tag;
                    showIndexList.Clear();
                    //firstbool = true;
                    foreach (var item in _placementConfigList)
                    {
                        if (item.tagstring == tag)
                        {
                            showIndexList.Add(_placementConfigList.IndexOf(item));
                        }
                    }
                }));

                MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action>
                {
                    {
                        "删除", (() => { taglist.RemoveAt(Index); })
                    }
                });
                EditorGUILayout.EndVertical();
            }
            newtagname = EditorGUILayout.TextField(newtagname, GUILayout.Width((innerBoxWidth / 2) * (1f / 3f) - 15f));
            if (MyGUI.Button("+"))
            {
                taglist.Add(newtagname);
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            // // 二级列表框 add by TangJian 2017/11/15 16:27:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width((innerBoxWidth / 2) * (2f / 3f)), GUILayout.ExpandHeight(true));
            SearchContext      = GUILayout.TextField(SearchContext);
            _listScrollViewPos = EditorGUILayout.BeginScrollView(_listScrollViewPos);

            if (!string.IsNullOrEmpty(SearchContext))
            {
                for (int i = 0; i < _placementConfigList.Count; i++)
                {
                    if (Regex.IsMatch(_placementConfigList[i].id.ToLower(), SearchContext))
                    {
                        ListID(i);
                    }
                }
            }
            else
            {
                for (int i = _placementConfigList.Count - 1; i >= 0; i--)
                {
                    if (!showIndexList.Contains(i))
                    {
                        continue;
                    }
                    EditorGUILayout.BeginHorizontal();
                    ListID(i);
                    EditorGUILayout.EndHorizontal();
                }
            }
            if (MyGUI.Button("+"))
            {
                _placementConfigList.Add(new tian.PlacementConfig());
                _placementConfigList[_placementConfigList.Count - 1].tagstring = currtagname;
                showIndexList.Add(_placementConfigList.Count - 1);
            }

            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 (_currPlacementConfig != null)
            {
                _currPlacementConfig.tagstring                 = MyGUI.TextFieldWithTitle("标签", _currPlacementConfig.tagstring);
                _currPlacementConfig.id                        = MyGUI.TextFieldWithTitle("ID", _currPlacementConfig.id);
                _currPlacementConfig.prefab                    = MyGUI.TextFieldWithTitle("prefab", _currPlacementConfig.prefab);
                _currPlacementConfig.AddRigidbody              = MyGUI.ToggleWithTitle("是否应用重力", _currPlacementConfig.AddRigidbody);
                _currPlacementConfig.colliderlayer             = (tian.ColliderLayer)MyGUI.EnumPopupWithTitle("碰撞layer", _currPlacementConfig.colliderlayer);
                _currPlacementConfig.colliderSizeType          = (tian.ColliderSizeType)MyGUI.EnumPopupWithTitle("size半自动与手工填写", _currPlacementConfig.colliderSizeType);
                _currPlacementConfig.placementData.deathEffect = MyGUI.TextFieldWithTitle("死亡动画|摧毁动画|爆炸动画", _currPlacementConfig.placementData.deathEffect);
                if (_currPlacementConfig.colliderSizeType != tian.ColliderSizeType.TextureRect)
                {
                    _currPlacementConfig.boundsPosition = MyGUI.Vector3WithTitle("碰撞体position", _currPlacementConfig.boundsPosition);
                    _currPlacementConfig.size           = MyGUI.Vector3WithTitle("碰撞体size", _currPlacementConfig.size);
                }
                _currPlacementConfig.NoNavMeshObstacle = MyGUI.ToggleWithTitle("不需要NavMeshObstacle", _currPlacementConfig.NoNavMeshObstacle);
                _currPlacementConfig.NoSortRenderPos   = MyGUI.ToggleWithTitle("不需要SortRenderPos", _currPlacementConfig.NoSortRenderPos);
                // Renderer朝向 add by TangJian 2018/12/18 15:57
                _currPlacementConfig.RendererOrientation =
                    (RendererOrientation)MyGUI.EnumPopupWithTitle("Renderer朝向", _currPlacementConfig.RendererOrientation);

                _currPlacementConfig.randerChoice = (tian.RanderChoice)MyGUI.EnumPopupWithTitle("Render选择", _currPlacementConfig.randerChoice);
                switch (_currPlacementConfig.randerChoice)
                {
                case tian.RanderChoice.Anim:
                    Spine.Unity.SkeletonDataAsset             skeletonDataAsset  = (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(_currPlacementConfig.SkeletonDataAssetpath, typeof(Spine.Unity.SkeletonDataAsset));
                    UnityEditor.Animations.AnimatorController animatorController = (UnityEditor.Animations.AnimatorController)AssetDatabase.LoadAssetAtPath(_currPlacementConfig.AnimatorControllerpath, typeof(UnityEditor.Animations.AnimatorController));
                    animatorController = (UnityEditor.Animations.AnimatorController)EditorGUILayout.ObjectField(new GUIContent("动画控制器"), animatorController, typeof(UnityEditor.Animations.AnimatorController), true);
                    skeletonDataAsset  = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField(new GUIContent("Skeleton"), skeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset), true);
                    _currPlacementConfig.SkeletonDataAssetpath  = AssetDatabase.GetAssetPath(skeletonDataAsset);
                    _currPlacementConfig.AnimatorControllerpath = AssetDatabase.GetAssetPath(animatorController);
                    _currPlacementConfig.ImagePath = "";
                    if (MyGUI.Button("打开纹理正面侧面编辑器"))
                    {
                        BoxTextureEditorWindow.Open(_currPlacementConfig);
                    }
                    break;

                case tian.RanderChoice.Image:
                    _currPlacementConfig.sceneDecorationPosition = (SceneDecorationPosition)MyGUI.EnumPopupWithTitle("显示位置", _currPlacementConfig.sceneDecorationPosition);
                    _usePathorImg = EditorGUILayout.ToggleLeft(new GUIContent("使用路径还是贴图"), _usePathorImg);

                    Material material = AssetDatabase.LoadAssetAtPath <Material>(_currPlacementConfig.materialPath);
                    material = (Material)EditorGUILayout.ObjectField("材质", material, typeof(Material), false);
                    _currPlacementConfig.materialPath = AssetDatabase.GetAssetPath(material);

                    if (_usePathorImg)
                    {
                        Texture2D img = (Texture2D)AssetDatabase.LoadAssetAtPath(_currPlacementConfig.ImagePath, typeof(Texture2D));
                        img = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("贴图"), img, typeof(Texture2D), _usePathorImg);
                        _currPlacementConfig.ImagePath = AssetDatabase.GetAssetPath(img);
                        EditorGUILayout.LabelField("图片路径:", _currPlacementConfig.ImagePath);
                    }
                    else
                    {
                        _currPlacementConfig.ImagePath = MyGUI.TextFieldWithTitle("图片路径:", _currPlacementConfig.ImagePath);

                        Texture2D img = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("贴图"), AssetDatabase.LoadAssetAtPath(_currPlacementConfig.ImagePath, typeof(Texture2D)), typeof(Texture2D), _usePathorImg);
                    }

                    if (MyGUI.Button("打开纹理正面侧面编辑器"))
                    {
                        BoxTextureEditorWindow.Open(_currPlacementConfig);
                    }

                    _currPlacementConfig.scaleType = (tian.ScaleType)MyGUI.EnumPopupWithTitle("使用整体缩放大小还是单独缩放大小", _currPlacementConfig.scaleType);
                    if (_currPlacementConfig.scaleType == tian.ScaleType.Alone)
                    {
                        _currPlacementConfig.AloneScale = MyGUI.FloatFieldWithTitle("单独缩放大小", _currPlacementConfig.AloneScale);
                    }
                    // currPlacementConfig.SkeletonDataAsset = null;
                    // currPlacementConfig.AnimatorController = null;
                    _currPlacementConfig.SkeletonDataAssetpath  = "";
                    _currPlacementConfig.AnimatorControllerpath = "";
                    break;

                default:
                    // currPlacementConfig.SkeletonDataAsset = null;
                    _currPlacementConfig.ImagePath              = "";
                    _currPlacementConfig.SkeletonDataAssetpath  = "";
                    _currPlacementConfig.AnimatorControllerpath = "";
                    // currPlacementConfig.AnimatorController = null;
                    break;
                }

                _currPlacementConfig.placementType = (tian.PlacementType)MyGUI.EnumPopupWithTitle("placementType", _currPlacementConfig.placementType);
                switch (_currPlacementConfig.placementType)
                {
                case tian.PlacementType.TreasureBox:
                    DrawDropItemList(ref _currPlacementConfig.placementData.dropItemList);
                    break;

                case tian.PlacementType.trap:
                    _currPlacementConfig.atk      = MyGUI.IntFieldWithTitle("Atk", _currPlacementConfig.atk);
                    _currPlacementConfig.trapType = (tian.TrapType)MyGUI.EnumPopupWithTitle("陷阱类型:", _currPlacementConfig.trapType);
                    switch (_currPlacementConfig.trapType)
                    {
                    case tian.TrapType.GroundStab:
                        GroundStabStateType groundStabStateType = (GroundStabStateType)_currPlacementConfig.trapState;
                        groundStabStateType            = (GroundStabStateType)MyGUI.EnumPopupWithTitle("地刺类型", groundStabStateType);
                        _currPlacementConfig.trapState = (int)groundStabStateType;
                        string st1 = "";
                        string st2 = "";
                        switch (_currPlacementConfig.trapState)
                        {
                        case 0:
                            st1 = "攻击延迟";
                            st2 = "关闭延迟";
                            break;

                        case 1:
                            st1 = "地刺地上停留时间";
                            st2 = "地刺地下停留时间";
                            _currPlacementConfig.float3 = MyGUI.FloatFieldWithTitle("首次停留时间", _currPlacementConfig.float3);
                            break;
                        }
                        _currPlacementConfig.float1 = MyGUI.FloatFieldWithTitle(st1, _currPlacementConfig.float1);
                        _currPlacementConfig.float2 = MyGUI.FloatFieldWithTitle(st2, _currPlacementConfig.float2);
                        break;
                    }
                    break;

                case tian.PlacementType.bucket:
                    _currPlacementConfig.placementData.hporCount = (tian.HporCount)MyGUI.EnumPopupWithTitle("打击数或hp", _currPlacementConfig.placementData.hporCount);
                    switch (_currPlacementConfig.placementData.hporCount)
                    {
                    case tian.HporCount.Hp:
                        _currPlacementConfig.placementData.atkhp = MyGUI.FloatFieldWithTitle("Hp", _currPlacementConfig.placementData.atkhp);
                        break;

                    case tian.HporCount.count:
                        _currPlacementConfig.placementData.atkcount = MyGUI.IntFieldWithTitle("被打击次数", _currPlacementConfig.placementData.atkcount);
                        break;

                    default:
                        break;
                    }

                    DrawDropItemList(ref _currPlacementConfig.placementData.dropItemList);
                    break;

                case tian.PlacementType.Ladder:
                    _currPlacementConfig.Laddertype = (laddertype)MyGUI.EnumPopupWithTitle("梯子在哪面", _currPlacementConfig.Laddertype);
                    break;

                case PlacementType.FenceDoor:
                    _currPlacementConfig.Laddertype = (laddertype)MyGUI.EnumPopupWithTitle("朝向", _currPlacementConfig.Laddertype);
                    break;

                default:
                    break;
                }


                // 材质类型
                _currPlacementConfig.matType       = (MatType)MyGUI.EnumPopupWithTitle("材质类型", _currPlacementConfig.matType);
                _currPlacementConfig.hitEffectType = (HitEffectType)MyGUI.EnumPopupWithTitle("打击效果类型", _currPlacementConfig.hitEffectType);

                //支持位移碰撞
                _currPlacementConfig.placementShake = MyGUI.ToggleWithTitle("支持位移碰撞", _currPlacementConfig.placementShake);
            }
            else
            {
                if (currtagname != null)
                {
                    EditorGUILayout.LabelField("当前选中标签:" + currtagname);
                    newtagnae = MyGUI.TextFieldWithTitle("新标签名称:", newtagnae);
                    if (MyGUI.Button("标签名称改动"))
                    {
                        if (taglist.Contains(currtagname))
                        {
                            //taglist[taglist.IndexOf(currtagname)] = newtagnae;
                            //currtagname = newtagnae;
                            foreach (var children in _placementConfigList)
                            {
                                if (children.tagstring == currtagname)
                                {
                                    children.tagstring = newtagnae;
                                }
                            }
                            taglist[taglist.IndexOf(currtagname)] = newtagnae;
                            currtagname = newtagnae;
                        }
                        newtagnae = "";
                    }
                }
            }

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


            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }