public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            spline = (SplineComputer)target;
            Undo.RecordObject(spline, "Edit Points");

            if (splines.Length == 1)
            {
                SplineEditorGUI.BeginContainerBox(ref pathEditor.open, "Edit");
                if (pathEditor.open)
                {
                    SplineEditor.Space lastSpace = pathEditor.space;
                    pathEditor.DrawInspector();
                    if (lastSpace != pathEditor.space)
                    {
                        SplinePrefs.pointEditSpace = (SplineComputer.Space)pathEditor.space;
                        SplinePrefs.SavePrefs();
                    }
                }
                else if (pathEditor.lastEditorTool != Tool.None && Tools.current == Tool.None)
                {
                    Tools.current = pathEditor.lastEditorTool;
                }
                SplineEditorGUI.EndContainerBox();
            }

            SplineEditorGUI.BeginContainerBox(ref computerEditor.open, "Spline Computer");
            if (computerEditor.open)
            {
                computerEditor.DrawInspector();
            }
            SplineEditorGUI.EndContainerBox();

            if (splines.Length == 1)
            {
                SplineEditorGUI.BeginContainerBox(ref triggersEditor.open, "Triggers");
                if (triggersEditor.open)
                {
                    triggersEditor.DrawInspector();
                }
                SplineEditorGUI.EndContainerBox();

                SplineEditorGUI.BeginContainerBox(ref debugEditor.open, "Editor Properties");
                if (debugEditor.open)
                {
                    debugEditor.DrawInspector();
                }
                SplineEditorGUI.EndContainerBox();
            }

            if (GUI.changed)
            {
                if (spline.isClosed)
                {
                    pathEditor.points[pathEditor.points.Length - 1] = pathEditor.points[0];
                }
                EditorUtility.SetDirty(spline);
            }
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            Node node = (Node)target;

            if (nodes.Length == 1)
            {
                if (addComp != null)
                {
                    string[] pointNames = new string[availablePoints.Length];
                    for (int i = 0; i < pointNames.Length; i++)
                    {
                        pointNames[i] = "Point " + (availablePoints[i] + 1);
                    }
                    if (availablePoints.Length > 0)
                    {
                        addPoint = EditorGUILayout.Popup("Link point", addPoint, pointNames);
                    }
                    else
                    {
                        EditorGUILayout.LabelField("No Points Available");
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        addComp  = null;
                        addPoint = 0;
                    }
                    if (addPoint >= 0 && availablePoints.Length > addPoint)
                    {
                        if (node.HasConnection(addComp, availablePoints[addPoint]))
                        {
                            EditorGUILayout.HelpBox("Connection already exists (" + addComp.name + "," + availablePoints[addPoint], MessageType.Error);
                        }
                        else if (GUILayout.Button("Link"))
                        {
                            AddConnection(addComp, availablePoints[addPoint]);
                        }
                    }
                }
                else
                {
                    SplineEditorGUI.BeginContainerBox(ref connectionsOpen, "Connections");
                    if (connectionsOpen)
                    {
                        ConnectionsGUI();
                    }
                    SplineEditorGUI.EndContainerBox();

                    Rect             rect = GUILayoutUtility.GetLastRect();
                    SplineComputer[] addComps;
                    SplineComputer   lastComp = addComp;
                    bool             dragged  = DreamteckEditorGUI.DropArea <SplineComputer>(rect, out addComps);
                    if (dragged && addComps.Length > 0)
                    {
                        SelectComputer(addComps[0]);
                    }

                    if (lastComp != addComp)
                    {
                        SceneView.RepaintAll();
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Connection UI not available when multiple Nodes are selected.", MessageType.Info);
            }

            SplineEditorGUI.BeginContainerBox(ref settingsOpen, "Settings");
            if (settingsOpen)
            {
                SettingsGUI();
            }
            SplineEditorGUI.EndContainerBox();
        }