Exemplo n.º 1
0
        void OnSceneGUI()
        {
            Coord2D coord = (Coord2D)target;

            DrawGrid();
            DrawTerrains();
            Event e = Event.current;

            if (e.isMouse)
            {
                if (e.button == 0 && e.clickCount == 1)
                {
                    if (e.type == EventType.mouseDown)
                    {
                        mousePos = e.mousePosition;
                    }
                    if (e.type == EventType.mouseUp)
                    {
                        if (mousePos == e.mousePosition)
                        {
                            // 左键单击设定或者取消地形
                            coord.SetTerrain(currentCoord);
                        }
                    }
                }

                if (e.button == 1 && e.clickCount == 1 && e.type == EventType.mouseUp)
                {
                    // 右键单击设定事件
                    Debug.Log("设定事件!");
                }
            }
            if (e.isKey)
            {
                if (e.control)
                {
                    if (e.type == EventType.keyUp && e.keyCode == KeyCode.S)
                    {
                        coord.SaveTerrain();
                        EditorApplication.SaveScene();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            Coord2D coord = (Coord2D)target;

            coord.UpdateTransform();
            coord.UpdateRotation();

            coord.position = EditorGUILayout.Vector3Field("位 置", coord.position);
            //coord.size = EditorGUILayout.Vector2Field("尺 寸", coord.size);
            coord.alpha = EditorGUILayout.Slider("透明度", coord.alpha, 0.0f, 1.0f);

            if (NGUIEditorTools.DrawHeader("单 元 格 设 定"))
            {
                NGUIEditorTools.BeginContents();
                GUILayout.BeginVertical();

                coord.gridSize     = EditorGUILayout.FloatField("尺 寸", coord.gridSize);
                coord.gridAngel    = EditorGUILayout.FloatField("角 度", coord.gridAngel);
                coord.gridRotation = EditorGUILayout.FloatField("旋 转", coord.gridRotation);
                coord.gridArea     = EditorGUILayout.FloatField("范 围", coord.gridArea);

                GUILayout.EndVertical();
                NGUIEditorTools.EndContents();
            }

            if (NGUIEditorTools.DrawHeader("地 形 绘 制"))
            {
                NGUIEditorTools.BeginContents();

                GUILayout.BeginVertical();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("选择笔刷");

                Coord2D.curBrushIndex = EditorGUILayout.Popup(Coord2D.curBrushIndex, options);

                EditorGUILayout.ColorField(Coord2D.curBrush.color);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("新 增"))
                {
                    BrushWindow window = BrushWindow.GetInstance();
                    window.title = "新增笔刷";
                    window.mod   = 0;
                    window.Input(new BrushVo());
                    window.ShowPopup();
                }
                if (GUILayout.Button("编 辑"))
                {
                    BrushWindow window = BrushWindow.GetInstance();
                    window.title = "编辑笔刷";
                    window.mod   = 1;
                    window.Input(Coord2D.curBrush);
                    window.ShowPopup();
                }
                if (GUILayout.Button("删 除"))
                {
                    Coord2D.DelBrush();
                    UpdateBrushOptions();
                    Coord2D.SaveBrushInfo();
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.EndVertical();

                NGUIEditorTools.EndContents();
            }

            EditorGUILayout.LabelField("场景视图按Q键进入拖动状态:");
            EditorGUILayout.LabelField("【单击鼠标左键编辑地形】【单击鼠标右键编辑事件】【再次单击取消】");

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("清空地形数据"))
            {
                if (EditorUtility.DisplayDialog("清空地形数据", "确定清空全部地形数据吗?(该操作不可撤销!!)", "确定", "取消"))
                {
                    coord.ClearTerrain();
                }
            }

            if (GUILayout.Button("清空事件数据"))
            {
                if (EditorUtility.DisplayDialog("清空事件数据", "确定清空全部事件数据吗?(该操作不可撤销!!)", "确定", "取消"))
                {
                    coord.ClearTerrain();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            coord.udata = EditorGUILayout.TextField("用户数据", coord.udata);

            if (coord.needSaveTerrain)
            {
                if (GUILayout.Button("保存场景"))
                {
                    coord.SaveTerrain();
                    EditorApplication.SaveScene();
                }
            }
        }