Ejemplo n.º 1
0
        void RenderConnections()
        {
            Node node = (Node)target;

            Node.Connection[] connections = node.GetConnections();
            Rect viewRect = new Rect(0, 0, Screen.width - 60, connections.Length * 25);

            GUILayout.Box("Connections", GUILayout.Width(Screen.width - 30), GUILayout.Height(Mathf.Min(Mathf.Max(viewRect.height, 30), 110) + 30));
            Rect rect = GUILayoutUtility.GetLastRect();

            SplineComputer[] addComps;
            SplineComputer   lastComp = addComp;
            bool             dragged  = SplineEditorGUI.DropArea <SplineComputer>(rect, out addComps);

            if (dragged && addComps.Length > 0)
            {
                SelectComputer(addComps[0]);
            }
            if (lastComp != addComp)
            {
                SceneView.RepaintAll();
            }
            rect.x      += 5;
            rect.width  -= 10;
            rect.height -= 30;
            rect.y      += 20;
            if (connections.Length > 0)
            {
                scroll = GUI.BeginScrollView(rect, scroll, viewRect);
                for (int i = 0; i < connections.Length; i++)
                {
                    GUI.Label(new Rect(0, i * 25, viewRect.width * 0.75f, 20), connections[i].computer.name + " at point " + connections[i].pointIndex);
                    if (GUI.Button(new Rect(viewRect.width - 20, i * 25, 20, 20), "x"))
                    {
                        Undo.RecordObject(node, "Remove connection");
                        Undo.RecordObject(connections[i].computer, "Remove node");
                        node.RemoveConnection(connections[i].computer, connections[i].pointIndex);
                    }
                }
                GUI.EndScrollView();
            }
            else
            {
                EditorGUI.HelpBox(rect, "Drag & Drop SplineComputers here to link their points.", MessageType.Info);
            }

            node.transformNormals  = EditorGUILayout.Toggle("Transform Normals", node.transformNormals);
            node.transformSize     = EditorGUILayout.Toggle("Transform Size", node.transformSize);
            node.transformTangents = EditorGUILayout.Toggle("Transform Tangents", node.transformTangents);

            if (connections.Length > 1)
            {
                node.type = (Node.Type)EditorGUILayout.EnumPopup("node type", node.type);
            }
        }
Ejemplo n.º 2
0
        void RenderConnections()
        {
            Node node = (Node)target;

            Node.Connection[] connections = node.GetConnections();
            scroll = EditorGUILayout.BeginScrollView(scroll, GUI.skin.box, GUILayout.Width(EditorGUIUtility.currentViewWidth - 30), GUILayout.Height(Mathf.Min(75 + connections.Length * 20, 200)));
            EditorGUILayout.LabelField("Connections");
            EditorGUILayout.Space();

            if (connections.Length > 0)
            {
                for (int i = 0; i < connections.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(connections[i].computer.name + " at point " + (connections[i].pointIndex + 1));
                    if (GUILayout.Button("Select", GUILayout.Width(70)))
                    {
                        Selection.activeGameObject = connections[i].computer.gameObject;
                    }
                    if (GUILayout.Button("x", GUILayout.Width(20)))
                    {
                        Undo.RecordObject(node, "Remove connection");
                        Undo.RecordObject(connections[i].computer, "Remove node");
                        node.RemoveConnection(connections[i].computer, connections[i].pointIndex);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Drag & Drop SplineComputers here to link their points.", MessageType.Info);
            }

            EditorGUILayout.EndScrollView();

            Rect rect = GUILayoutUtility.GetLastRect();

            SplineComputer[] addComps;
            SplineComputer   lastComp = addComp;
            bool             dragged  = SplineEditorGUI.DropArea <SplineComputer>(rect, out addComps);

            if (dragged && addComps.Length > 0)
            {
                SelectComputer(addComps[0]);
            }
            if (lastComp != addComp)
            {
                SceneView.RepaintAll();
            }

            node.transformNormals  = EditorGUILayout.Toggle("Transform Normals", node.transformNormals);
            node.transformSize     = EditorGUILayout.Toggle("Transform Size", node.transformSize);
            node.transformTangents = EditorGUILayout.Toggle("Transform Tangents", node.transformTangents);

            EditorGUI.BeginChangeCheck();
            if (connections.Length > 1)
            {
                node.type = (Node.Type)EditorGUILayout.EnumPopup("Node type", node.type);
            }
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
                node.UpdateConnectedComputers();
            }
        }