Ejemplo n.º 1
0
    // 重写Inspector检视面板
    public override void OnInspectorGUI()
    {
        np.StartInit       = EditorGUILayout.Toggle("运行显示", np.StartInit);
        np.StartDataConfig = EditorGUILayout.Toggle("启用数据", np.StartDataConfig);
        if (!string.IsNullOrEmpty(np.mDataConfig))
        {
            if (GUILayout.Button("删除数据文件"))
            {
                np.mDataConfig = null;
            }
        }
        //数据序列化
        if (np.StartDataConfig)
        {
            if (!string.IsNullOrEmpty(np.mDataConfig))
            {
                GUILayout.Label("---------------------------------------------------");
                GUILayout.Label("数据解析:" + np.mDataConfig);
                GUILayout.Label("---------------------------------------------------");
            }
            if (np.mUnitObject != null)
            {
                MyEdior.DrawConverter.DrawObject(np.mUnitObject, null);
                if (GUILayout.Button("保存数据"))
                {
                    np.mDataConfig = StringSerialize.Serialize(np.mUnitObject);
                }
            }
        }

        string tempName = np.StartConfig ? "保存配置" : "Delete";

        mSelectPrefab.InitGUI();
        np.nTypeKey = mSelectPrefab.getSelectKey();

        if (mCurSelectName != np.nTypeKey)
        {
            mCurSelectName = np.nTypeKey;
        }
        if (np.mUnitObject == null)
        {
            GUILayout.Space(10);
            if (GUILayout.Button("Create"))
            {
                np.SetActive(true);
            }
        }
        else
        {
            GUILayout.Space(10);
            if (GUILayout.Button(tempName))
            {
                GameObject.DestroyImmediate(np.mUnitObject.gameObject);
            }
        }

        MyEdior.KeepScene();
    }
Ejemplo n.º 2
0
    // 重写Inspector检视面板
    public override void OnInspectorGUI()
    {
        KeyStr = np.mKey;
        EditorGUILayout.LabelField("带有 " + KeyStr + " 的物体将会自动保存");
        nChangeKey = EditorGUILayout.Toggle("打开Key修改按钮", nChangeKey);

        if (nChangeKey)
        {
            GUILayout.Label("输入要保存的Key:");
            np.mKey = GUILayout.TextField(np.mKey);
            if (np.mKey == null || np.mKey == "")
            {
                np.mKey = "F_";
            }
        }

        nOpenCreate = EditorGUILayout.Toggle("打开创建按钮", nOpenCreate);
        if (nOpenCreate)
        {
            mSelectPrefab.InitGUI();
            GUILayout.Space(10);
            if (GUILayout.Button("Create"))
            {
                SceneManager.instance.Create(mSelectPrefab.getSelectKey(), np.gameObject);
            }
        }
        else
        {
            GUILayout.Space(10);
            if (isUpdateShow)
            {
                EditorGUILayout.LabelField("有更新,请点击Apply进行更新");
            }
            if (GUILayout.Button("Apply"))
            {
                applyData();
            }
        }
        MyEdior.KeepScene();
    }
Ejemplo n.º 3
0
    void OnSceneGUI()
    {
        Event     curEvent   = Event.current;
        EventType mousetType = curEvent.type;

        if (mousetType == EventType.Layout)
        {
            HandleUtility.AddDefaultControl(GetInstanceID());
        }

        float   width   = 0.2f;
        Vector3 verSize = HandleUtility.WorldToGUIPoint(Vector3.one) - HandleUtility.WorldToGUIPoint(Vector3.zero);

        verSize.x = Mathf.Abs(verSize.x) * width * 1.2f;

        bool IsRight = false;
        var  paths   = PP.pathData;

        for (int i = 0; i < paths.Count; i++)
        {
            var p = paths[i];

            Handles.color = Color.blue;
            for (int j = 0; j < p.mIds.Count; j++)
            {
                Handles.DrawAAPolyLine(3, PP.transform.TransformPoint(p.pos), PP.transform.TransformPoint(PP.GetPathById(p.mIds[j]).pos));
            }
            Handles.color = Color.white;

            Vector3 worldPos = PP.transform.TransformPoint(p.pos);
            if (mCurSelectIndex != i)
            {
                var pos = Handles.FreeMoveHandle(worldPos, Quaternion.identity, width, Vector3.one, Handles.SphereHandleCap);
                if (!Event.current.shift)
                {
                    p.pos = PP.transform.InverseTransformPoint(pos);
                }
            }
            else
            {
                var pos = Handles.FreeMoveHandle(worldPos, Quaternion.identity, width, Vector3.one, Handles.CubeHandleCap);
                if (!Event.current.shift)
                {
                    p.pos = PP.transform.InverseTransformPoint(pos);
                }
            }

            if (mousetType == EventType.MouseUp)
            {
                Vector3 point = HandleUtility.WorldToGUIPoint(worldPos);
                Rect    rect  = new Rect(point.x - verSize.x / 2, point.y - verSize.x / 2, verSize.x, verSize.x);
                // 是否鼠标在控制柄上
                if (rect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.shift)
                    {
                        if (mCurSelectIndex != i)
                        {
                            var selectPathData = paths[mCurSelectIndex];
                            if (selectPathData.mIds.Contains(i))
                            {
                                selectPathData.mIds.Remove(i);
                                p.mIds.Remove(mCurSelectIndex);
                            }
                            else
                            {
                                selectPathData.mIds.Add(i);
                                p.mIds.Add(mCurSelectIndex);
                            }
                        }
                    }

                    // 显示缩放图标的箭头
                    mCurSelectIndex = i;
                    if (Event.current.button == 1)
                    {
                        IsRight = true;
                    }
                }
            }
        }


        if (Event.current.shift)
        {
            if (paths.Count > mCurSelectIndex)
            {
                Color lastColor = Handles.color;
                Handles.color = Color.green;
                Handles.DrawAAPolyLine(2, PP.transform.TransformPoint(paths[mCurSelectIndex].pos), GetMousePostion());
                Handles.color = lastColor;
                SceneView.currentDrawingSceneView.Repaint();
                HandleUtility.Repaint();
            }
        }


        //规定GUI显示区域
        GUILayout.BeginArea(new Rect(Screen.width - 250, 60, 220, 250));
        GUILayout.Box("", GUILayout.Width(210), GUILayout.Height(250));
        GUILayout.EndArea();
        Color tempColor = GUI.color;

        GUI.color = Color.red;
        GUILayout.BeginArea(new Rect(Screen.width - 250, 70, 150, 250));
        GUILayout.Label("按shift进行连线");
        GUILayout.Label("当前操作: " + mCurSelectIndex.ToString());
        GUI.color = tempColor;
        GUILayout.EndArea();
        if (PP.pathData.Count > mCurSelectIndex && mCurSelectIndex >= 0)
        {
            GUILayout.BeginArea(new Rect(Screen.width - 250, 110, 150, 50));
            var pd = PP.pathData[mCurSelectIndex];
            pd.pos = EditorGUILayout.Vector3Field("位置:", pd.pos);
            GUILayout.EndArea();
        }
        else
        {
            mCurSelectIndex = 0;
        }

        GUI.color = tempColor;

        if (!IsRight && (mousetType == EventType.MouseDown && Event.current.button == 1))
        {
            //绘制路径
            Vector3 viewworldPos = GetMousePostion();
            var     menu         = new GenericMenu();
            menu.AddItem(new GUIContent("添加节点"), false, CreateNode, viewworldPos);
            menu.ShowAsContext();
            SceneView.currentDrawingSceneView.Repaint();
            HandleUtility.Repaint();
        }

        //规定GUI显示区域
        GUILayout.BeginArea(new Rect(Screen.width - 100, Screen.height - 100, 100, 100));

        GUI.color = Color.red;
        if (GUILayout.Button("删除点", GUILayout.Width(100), GUILayout.Height(25)))
        {
            if (PP.pathData.Count > mCurSelectIndex)
            {
                for (int i = 0; i < PP.pathData.Count; i++)
                {
                    var point = PP.pathData[i];
                    for (int j = point.mIds.Count - 1; j >= 0; j--)
                    {
                        if (point.mIds[j] == mCurSelectIndex)
                        {
                            point.mIds.Remove(mCurSelectIndex);
                        }
                        else if (point.mIds[j] > mCurSelectIndex)
                        {
                            point.mIds[j] = point.mIds[j] - 1;
                        }
                    }
                }
                PP.pathData.RemoveAt(mCurSelectIndex);
                mCurSelectIndex = 0;
                SceneView.currentDrawingSceneView.Repaint();
                HandleUtility.Repaint();
            }
        }


        GUILayout.EndArea();
        MyEdior.KeepScene();
    }
Ejemplo n.º 4
0
 // 重写Inspector检视面板
 public override void OnInspectorGUI()
 {
     np.IsNoPack  = EditorGUILayout.Toggle("不打包模式(打一次包可用)", np.IsNoPack);
     np.DebugType = (FEngine.FDebugType)EditorGUILayout.EnumPopup("Debug类型", np.DebugType);
     MyEdior.KeepScene();
 }