Ejemplo n.º 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>
            {
                {
                    "读取", loadSkill
                },
                {
                    "保存", saveSkill
                }
            });

            baseScrollViewPos = EditorGUILayout.BeginScrollView(baseScrollViewPos);

            using (new EditorGUILayout.VerticalScope())
            {
                //路径
                EditorGUILayout.BeginVertical(boxStyle, GUILayout.Height(innerBoxHeight / 24));
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField(skillDataFile);
                }
                EditorGUILayout.EndVertical();
                //list 内容
                EditorGUILayout.BeginVertical(boxStyle, GUILayout.Height(innerBoxHeight / 2f));
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 3),
                                                  GUILayout.Height(innerBoxHeight / 2));
                    EditorGUILayout.BeginVertical();
                    SearchContext     = GUILayout.TextField(SearchContext);
                    listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos);

                    #region list

                    if (!string.IsNullOrEmpty(SearchContext))
                    {
                        for (int i = 0; i < skillDataList.Count; i++)
                        {
                            if (Regex.IsMatch(skillDataList[i].id.ToLower(), SearchContext))
                            {
                                ListID(i);
                            }
                        }
                    }
                    else
                    {
                        for (int i = skillDataList.Count - 1; i >= 0; i--)
                        {
                            EditorGUILayout.BeginHorizontal();
                            ListID(i);
                            EditorGUILayout.EndHorizontal();
                        }
                    }

                    #endregion

                    if (MyGUI.Button("+"))
                    {
                        SkillData skillData = new SkillData(new SkillData("Front"), new SkillData("Centre"), new SkillData("Back"));
                        skillData.id            = "New";
                        skillData.IsPhasesSkill = true;
                        skillDataList.Add(skillData);
                        CreatTreeNode();
                    }

                    EditorGUILayout.EndScrollView();
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 6),
                                                  GUILayout.Height(innerBoxHeight / 2));

                    currentSkillTreeNode(currSkillData, new Rect(innerBoxWidth / 3 + 10, innerBoxHeight / 24 + 10, innerBoxWidth / 6, innerBoxHeight / 2f));
                    GUILayout.Space(50);

                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2),
                                                  GUILayout.Height(innerBoxHeight / 2));
                    EditorGUILayout.BeginVertical();
                    editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos);

                    if (currSkillData.skillDatas.Count > 0 && currentNode != null)
                    {
                        CurrSkillDataInput(currentNode.nodeSkillData);
                    }
                    else
                    {
                        CurrSkillDataInput(currSkillData);
                    }

                    EditorGUILayout.EndScrollView();
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
                //测试
                EditorGUILayout.BeginVertical(boxStyle, GUILayout.Height(innerBoxHeight / 12));
                using (new EditorGUILayout.VerticalScope())
                {
                    if (Application.isPlaying)
                    {
                        using (new EditorGUILayout.VerticalScope())
                        {
                            usecount        = MyGUI.IntFieldWithTitle("使用次数:", usecount);
                            inetal          = MyGUI.FloatFieldWithTitle("间隔时间:", inetal);
                            testSkillOffset = MyGUI.Vector3WithTitle("释放位置:", testSkillOffset);
                        }

                        roleTarget = (GameObject)EditorGUILayout.ObjectField(roleTarget, typeof(GameObject), true);

                        if (MyGUI.Button("测试技能"))
                        {
                            var            playerObject   = GameObject.Find("Player1");
                            RoleController roleController = playerObject.GetComponent <RoleController>();
                            //SkillManager.Instance.UseSkill(currSkillData, playerObject.transform, roleController.RoleData.TeamId, roleController.GetDirection());
                            EditorCoroutineSequenceRunner.RemoveCoroutine("SkillTest");
                            EditorCoroutineSequenceRunner.AddCoroutineIfNot("SkillTest",
                                                                            TestAnimEffect(usecount, inetal, roleController.RoleData.TeamId, playerObject.transform,
                                                                                           testSkillOffset, roleController.GetDirection()));
                        }
                    }
                }
                EditorGUILayout.EndVertical();
                //Spine
                EditorGUILayout.BeginVertical(boxStyle, GUILayout.Height(innerBoxHeight / 4));
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (Application.isPlaying == false)
                    {
                        if (!string.IsNullOrEmpty(currSkillData.SkeletonDataAssetPath))
                        {
                            SkeletonAnimOnGUI(boxStyle, position.width, position.height / 3.2f);
                            panduandanqian();
                            //var skeletondataasset = (SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(currSkillData.SkeletonDataAssetPath, typeof(SkeletonDataAsset));
                            //if (skeletondataasset != null)
                            {
                                //Selection.activeObject = skeletondataasset;
                                //PreviewEditor = UnityEditor.Editor.CreateEditor(Selection.activeObject, typeof(Spine.Unity.Editor.SkeletonPreviewEditor)) as Spine.Unity.Editor.SkeletonPreviewEditor;
                                if (currSkillData.onoffCollider && Selection.activeObject is SkeletonDataAsset)
                                {
                                    PreviewEditor.AddDrawExtraGuideLineAction(currSkillData.id, (Camera camera) =>
                                    {
                                        Handles.color = Color.green;
                                        Handles.DrawWireCube(currSkillData.colliderCenter, currSkillData.colliderSize);
                                    });
                                }

                                if (currSkillData.onoffDamage && Selection.activeObject is SkeletonDataAsset)
                                {
                                    PreviewEditor.AddDrawExtraGuideLineAction(currSkillData.id + "Damage",
                                                                              (Camera camera) =>
                                    {
                                        Handles.color = Color.red;
                                        Handles.DrawWireCube(currSkillData.DamageColliderCenter,
                                                             currSkillData.DamageColliderSize);
                                    });
                                }

                                if (currSkillData.onoffFocus && Selection.activeObject is SkeletonDataAsset)
                                {
                                    PreviewEditor.AddDrawExtraGuideLineAction(currSkillData.id + "focus",
                                                                              (Camera camera) =>
                                    {
                                        Handles.color = Color.red;
                                        Handles.ArrowHandleCap(0, currSkillData.focuspos, Quaternion.Euler(0, 0, 0),
                                                               1, UnityEngine.EventType.Repaint);
                                    });
                                }
                            }
                        }
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            foreach (SceneComponent _sceneComponent in targets)
            {
                if (PrefabUtility.GetPrefabType(_sceneComponent.gameObject) == PrefabType.PrefabInstance)
                {
                    _sceneComponent.MoveByGridPos(Vector3.zero);
                }
            }

            if (MyGUI.Button("更新组件"))
            {
                EditorCoroutineSequenceRunner.AddCoroutineIfNot("更新组件", targets.MyToList <SceneComponent>().Editor_UpdateToPrefab());
            }

            if (MyGUI.Button("生成2d图片"))
            {
                foreach (SceneComponent item in targets)
                {
                    if (item is SceneSlopeComponent)
                    {
                        (item as SceneSlopeComponent).CreateTexture2D();
                    }

                    if (item is BackWall)
                    {
                        (item as BackWall).CreateTexture2D();
                    }

                    if (item is SceneSideWallComponent)
                    {
                        (item as SceneSideWallComponent).CreateTexture2D();
                    }

                    if (item is SceneCenterWallComponent)
                    {
                        (item as SceneCenterWallComponent).CreateTexture2D();
                    }

                    if (item is SceneSlopeWallComponent)
                    {
                        (item as SceneSlopeWallComponent).CreateTexture2D();
                    }

                    if (item is SceneTriangleWallComponent)
                    {
                        (item as SceneTriangleWallComponent).CreateTexture2D();
                    }

                    if (item is Ground)
                    {
                        (item as Ground).CreateTexture2D();
                    }
                }
            }

            SceneComponent sceneComponent = (target as SceneComponent);

            GUILayout.Label("ComponentType: " + sceneComponent.ComponentType);

            if (PrefabUtility.GetPrefabType(sceneComponent.gameObject) == PrefabType.Prefab)
            {
                if (MyGUI.Button("生成纹理"))
                {
                    for (int i = 0; i < targets.Length; i++)
                    {
                        SceneComponent _sceneComponent = targets[i] as SceneComponent;
                        if (_sceneComponent != null)
                        {
                            EditorUtility.DisplayProgressBar("生成纹理", "生成纹理: " + _sceneComponent.name, (float)i / targets.Length);

                            Tools.ModifyPrefab(_sceneComponent.gameObject, (GameObject go) =>
                            {
                                go.GetComponent <SceneComponent>().Editor_Build();
                            });
                        }
                    }

                    EditorUtility.ClearProgressBar();
                }
            }

            DrawDefaultInspector();

            // 刷新组件的翻转 add by TangJian 2018/10/31 14:25
            foreach (SceneComponent _sceneComponent in targets)
            {
                _sceneComponent.RefreshFlip();
            }
        }
Ejemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            if (sceneComponentGroup == null)
            {
                return;
            }

            if (MyGUI.Button("更新场景组件到最新的预制体"))
            {
                List <SceneComponent> sceneComponentList = sceneComponentGroup.gameObject.GetComponentList <SceneComponent>();
                EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateToPrefab(), 9999);
            }

            if (MyGUI.Button("更新组件排序"))
            {
                List <SceneComponent> sceneComponentList = sceneComponentGroup.gameObject.GetComponentList <SceneComponent>();
                EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateRendererShader(), 9999);
                EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateSortRenderer(), 9999);
            }

            if (GUILayout.Button("给所有渲染节点添加阴影"))
            {
                List <Renderer> renderers = sceneComponentGroup.gameObject.GetComponentList <Renderer>();
                foreach (var renderer in renderers)
                {
                    Light.ShadowRenderer shadowRenderer = renderer.gameObject.AddComponentUnique <Light.ShadowRenderer>();
                    //if (renderer.sharedMaterial.mainTexture != null)
                    //{
                    //    string texturePath = AssetDatabase.GetAssetPath(renderer.sharedMaterial.mainTexture);
                    //    string normalPath = texturePath.Insert(texturePath.LastIndexOf('.'), "_normal");
                    //    Debug.Log("texturePath =" + texturePath);
                    //    Debug.Log("normalPath =" + normalPath);
                    //    Texture2D normalTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(normalPath);
                    //    if (normalTexture != null)
                    //    {
                    //        shadowRenderer.ShadowTexture = normalTexture;
                    //    }
                    //}
                }
            }

            if (GUILayout.Button("保存所有场景预制体"))
            {
                List <SceneController> sceneControllers = sceneComponentGroup.gameObject.GetComponentList <SceneController>();
                EditorCoroutineSequenceRunner.AddCoroutine(sceneControllers.Editor_ApplySceneController(), 9999);
            }

            if (GUILayout.Button("更新组件到最新->保存场景"))
            {
                List <SceneController> sceneControllers = sceneComponentGroup.gameObject.GetComponentList <SceneController>();
                foreach (var sceneController in sceneControllers)
                {
                    List <SceneComponent> sceneComponentList = sceneController.gameObject.GetComponentList <SceneComponent>();
                    EditorCoroutineSequenceRunner.AddCoroutine(sceneComponentList.Editor_UpdateToPrefab(), 9999);
                }

                EditorCoroutineSequenceRunner.AddCoroutine(sceneControllers.Editor_InitSceneObjectControllers(), 9999);
                EditorCoroutineSequenceRunner.AddCoroutine(sceneControllers.Editor_ApplySceneController(), 9999);
            }

            if (MyGUI.Button("设置场景地形组件的SortRenderer"))
            {
                List <SceneComponent> sceneComponentList = sceneComponentGroup.gameObject.GetComponentList <SceneComponent>();

                sceneComponentList.Editor_UpdateSideWallRendererSort();
                //Editor_UpdatePlacementsRendererSort
            }
        }
Ejemplo n.º 4
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>
            {
                {
                    "读取", Load
                },
                {
                    "保存", Save
                }
            });

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 3), GUILayout.ExpandHeight(true));
            int removeIndex = -1;
            int copyIndex   = -1;

            SearchContext = GUILayout.TextField(SearchContext);
            verVector2    = GUILayout.BeginScrollView(verVector2);


            if (!string.IsNullOrEmpty(SearchContext))
            {
                for (int i = 0; i < animEffectSaveData.animEffectDataList.Count; i++)
                {
                    if (Regex.IsMatch(animEffectSaveData.animEffectDataList[i].id.ToLower(), SearchContext))
                    {
                        ListID(i);
                    }
                }
            }
            else
            {
                for (int i = 0; i < animEffectSaveData.animEffectDataList.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    ListID(i);
                    GUILayout.EndHorizontal();
                }
            }


            GUILayout.EndScrollView();

            if (MyGUI.Button("+"))
            {
                animEffectSaveData.animEffectDataList.Add(new AnimEffectData());
            }

            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 6), GUILayout.ExpandHeight(true));
            //  二级
            AnimEffectData animEffectData;

            if (animEffectSaveData.animEffectDataList.TryGet(focusIndex, out animEffectData))
            {
//                    int removeIndex = -1;
//                    int copyIndex = -1;

                for (int i = 0; i < animEffectData.animEffectDataList.Count; i++)
                {
                    GUILayout.BeginHorizontal();

                    int Index = MyGUIExtend.Instance.ListSingleButton("AnimEditor_1", i + ":" + animEffectData.animEffectDataList[i].id,
                                                                      i, (
                                                                          () =>
                    {
                        subFocusIndex = i;
                    }));

                    MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action>
                    {
                        {
                            "复制", (() =>
                            {
                                animEffectData.animEffectDataList.Add(
                                    Tools.DepthClone(animEffectData.animEffectDataList[Index]));
                            })
                        },
                        {
                            "删除", (() => { animEffectData.animEffectDataList.RemoveAt(Index); })
                        }
                    });


                    GUILayout.EndHorizontal();
                }

                if (animEffectData.animEffectType == AnimEffectData.AnimEffectType.Group || animEffectData.animEffectType == AnimEffectData.AnimEffectType.Random)
                {
                    if (MyGUI.Button("+"))
                    {
                        animEffectData.animEffectDataList.Add(new AnimEffectData());
                    }
                }
            }
            EditorGUILayout.EndVertical();



            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            AnimEffectData animeffectData;

            if (animEffectSaveData.animEffectDataList.TryGet(focusIndex, out animeffectData))
            {
                if (subFocusIndex >= 0)
                {
                    if (animeffectData.animEffectDataList.TryGet(subFocusIndex, out animeffectData))
                    {
                    }
                    else
                    {
                        // 找不到subFocusIndex位置的AnimEffectData
                        return;
                    }
                }

                animEffectDataFieldScrollPos = MyGUI.AnimEffectDataField(animeffectData, animEffectDataFieldScrollPos);


                if (Application.isPlaying)
                {
                    testTimes       = MyGUI.IntFieldWithTitle("测试次数", testTimes);
                    testInterval    = MyGUI.FloatFieldWithTitle("间隔时间", testInterval);
                    moveOrientation = MyGUI.Vector3WithTitle("移动方向", moveOrientation);
                    testPosition    = MyGUI.Vector3WithTitle("位置", testPosition);
                    testFlip        = MyGUI.ToggleWithTitle("翻转", testFlip);


                    if (MyGUI.Button("测试特效"))
                    {
                        EditorCoroutineSequenceRunner.RemoveCoroutine("AnimEffectTest");
                        EditorCoroutineSequenceRunner.AddCoroutineIfNot("AnimEffectTest", TestAnimEffect(animeffectData, testTimes, testInterval));
                    }
                }
            }
            EditorGUILayout.EndVertical();


            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 5
0
        //SkillListManagerDataAsset skillManagerDataAsset;

        void OnGUI()
        {
            MyGUI.Layout(
                position,
                boxStyle,
                Layout,
                (Rect position) =>
            {
                EditorGUILayout.LabelField(skillDataFile);
                if (MyGUI.Button("读取"))
                {
                    Load();
                }

                if (MyGUI.Button("保存"))
                {
                    Save();
                }
            },
                (Rect position) =>
            {
                int removeIndex = -1;
                int copyIndex   = -1;
                if (skillListDatas.Count > 0)
                {
                    for (int i = 0; i < skillListDatas.Count; i++)
                    {
                        GUILayout.BeginHorizontal();
                        if (MyGUI.Button("复制", GUILayout.Width(20)))
                        {
                            copyIndex = i;
                        }
                        if (MyGUI.Button(skillListDatas[i].id))
                        {
                            currskillListData = skillListDatas[i];
                            focusIndex        = i;
                        }
                        if (MyGUI.Button("-", GUILayout.Width(20)))
                        {
                            removeIndex = i;
                        }
                        GUILayout.EndHorizontal();
                    }
                }

                if (removeIndex >= 0)
                {
                    skillListDatas.RemoveAt(removeIndex);
                }

                if (copyIndex >= 0)
                {
                    //SkillListData skill = skillListDatas[copyIndex];
                    skillListDatas.Add(Tools.DepthClone(skillListDatas[copyIndex]));
                }

                if (MyGUI.Button("+"))
                {
                    skillListDatas.Add(new SkillListSaveData());
                }
            },
                (Rect position) =>
            {
                if (currskillListData != null)
                {
                    Scrollpos            = EditorGUILayout.BeginScrollView(Scrollpos);
                    currskillListData.id = MyGUI.TextFieldWithTitle("id:", currskillListData.id);
                    currskillListData.roleSkillListFrameEventData.RoleSkillListType = (RoleSkillListType)MyGUI.EnumPopupWithTitle("类型:", currskillListData.roleSkillListFrameEventData.RoleSkillListType);
                    currskillListData.roleSkillListFrameEventData = MyGUI.Skilldatalistfield(currskillListData.roleSkillListFrameEventData, currskillListData.roleSkillListFrameEventData.RoleSkillListType);
                    EditorGUILayout.EndScrollView();
                }
            },
                (Rect position) =>
            {
                if (Application.isPlaying)
                {
                    testTimes    = MyGUI.IntFieldWithTitle("测试次数", testTimes);
                    testInterval = MyGUI.FloatFieldWithTitle("间隔时间", testInterval);
                    //moveOrientation = MyGUI.Vector3WithTitle("移动方向", moveOrientation);
                    //testPosition = MyGUI.Vector3WithTitle("位置", testPosition);
                    testFlip = MyGUI.ToggleWithTitle("翻转", testFlip);


                    if (MyGUI.Button("测试特效"))
                    {
                        EditorCoroutineSequenceRunner.RemoveCoroutine("SkillList");
                        EditorCoroutineSequenceRunner.AddCoroutineIfNot("SkillList", TestAnimEffect(currskillListData, testTimes, testInterval));
                    }
                }
            });
        }