Пример #1
0
 void Awake()
 {
     transform          = GetComponent <Transform>();
     lowpass            = GetComponent <AudioLowPassFilter>();
     audioSource        = GetComponent <AudioSource>();
     _transientNodes    = new Dictionary <Node, TransientNode>();
     _listenerTransform = FindObjectOfType <AudioListener>().transform;
     _allNodes          = AudioPropagateNodeGroup.GetAllNodes();
     audioSource.volume = 0;
 }
Пример #2
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;
            }
        }
Пример #3
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);
                }
            }
        }
Пример #4
0
        void DrawNode(Node node, int nodeIndex)
        {
            if (Handles.Button(node.position, Quaternion.identity, .3f, .4f, Handles.SphereCap))
            {
                if (isLinking && selectedNode != null)
                {
                    AudioPropagateNodeGroup pGroup = (AudioPropagateNodeGroup)target;
                    pGroup.ConnectNodes(selectedNode, node);
                    isLinking = false;
                }
                selectedNode = node;
            }

            //Handles.Label(node.position, node.id.ToString());

            for (int i = 0; i < node.connections.Count; ++i)
            {
                var otherNode = node.connections[i];

                Handles.DrawLine(node.position, otherNode.position);
            }
        }