示例#1
0
        public override void OnInspectorGUI()
        {
            AudioPropagateNodeGroup pGroup = (AudioPropagateNodeGroup)target;

            PropagateLogoGUI.DrawLogo();

            pGroup.maxConnectDistance = EditorGUILayout.FloatField("Max Connect Distance", pGroup.maxConnectDistance);

            if (GUILayout.Button("Add Node"))
            {
                var     view     = SceneView.currentDrawingSceneView;
                Vector3 position = pGroup.transform.position;
                if (selectedNode != null)
                {
                    position = selectedNode.position;
                }
                if (view != null)
                {
                    Transform  camT = view.camera.transform;
                    RaycastHit hit;
                    if (Physics.Raycast(camT.position, camT.forward, out hit, Mathf.Infinity))
                    {
                        position = hit.point + (hit.normal * 5f);
                    }
                    else
                    {
                        position = camT.position + (camT.forward * 5.0f);
                    }
                }
                selectedNode = pGroup.AddNode(position);
                SceneView.RepaintAll();
            }
            if (GUILayout.Button("Delete Node") && selectedNode != null)
            {
                pGroup.DeleteNode(selectedNode);
                selectedNode = null;
                SceneView.RepaintAll();
            }

            if (selectedNode != null)
            {
                string buttonText = isLinking ? "Cancel Link Node" : "Link Node";
                if (GUILayout.Button(buttonText))
                {
                    isLinking = !isLinking;
                }
            }
            else
            {
                isLinking = false;
            }
        }
示例#2
0
        void OnSceneGUI()
        {
            Tools.current = Tool.None;
            AudioPropagateNodeGroup pGroup = (AudioPropagateNodeGroup)target;

            Handles.color = new Color(0, .5f, 1f, .5f);

            if (pGroup.nodes != null && pGroup.nodeCount > 0)
            {
                for (int nodeIndex = 0; nodeIndex < pGroup.nodeCount; ++nodeIndex)
                {
                    DrawNode(pGroup.nodes[nodeIndex], nodeIndex);
                }
            }

            if (selectedNode != null)
            {
                UpdateNode(selectedNode);
                if (Event.current.commandName == "FrameSelected")
                {
                    SceneView.lastActiveSceneView.LookAt(selectedNode.position, SceneView.lastActiveSceneView.rotation, 5.0f);
                    Event.current.Use();
                }

                if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "Duplicate")
                {
                    selectedNode = pGroup.AddNode(selectedNode.position);
                    Event.current.Use();
                }

                if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "Delete")
                {
                    pGroup.DeleteNode(selectedNode);
                    selectedNode = null;
                    Event.current.commandName = "";
                    Event.current.Use();
                }

                if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.C)
                {
                    Debug.Log(selectedNode.connections.Count);
                }
            }
        }