Пример #1
0
        /// <summary>
        /// EDITOR: Draw the left connector on the node in the graph
        /// </summary>
        protected virtual void DrawInput()
        {
            if (this.input == null)
            {
                return;
            }

            Vector2 tempPos = new Vector2(this.nodeRect.x, this.nodeRect.y);

            tempPos.x -= this.input.Window.width;
            tempPos.y += (this.nodeRect.height / 2);
            this.input.Window.position = tempPos;

            if (ConnectorTexture == null)
            {
                ConnectorTexture = EditorGUIUtility.Load("icons/animationkeyframe.png") as Texture2D;
            }
            GUI.DrawTexture(this.input.Window, ConnectorTexture);

            for (int i = 0; i < this.input.ConnectedNodes.Length; i++)
            {
                AudioNodeOutput tempOutput = this.input.ConnectedNodes[i];
                DrawCurve(tempOutput.Center, this.input.Center);
            }
        }
Пример #2
0
 /// <summary>
 /// EDITOR: Add a right connector to the node when it is first created
 /// </summary>
 protected void AddOutput()
 {
     this.output = ScriptableObject.CreateInstance <AudioNodeOutput>();
     AssetDatabase.AddObjectToAsset(this.output, this);
     this.output.name       = this.name + "Output";
     this.output.ParentNode = this;
 }
Пример #3
0
        /// <summary>
        /// Perform necessary actions for the left mouse button being pushed this frame
        /// </summary>
        /// <param name="e">The input event handled in Unity</param>
        private void HandleLeftClick(Event e)
        {
            this.leftButtonDown     = true;
            this.rightButtonClicked = false;
            this.selectedOutput     = GetOutputAtPosition(e.mousePosition);

            this.selectedNode = GetNodeAtPosition(e.mousePosition);
        }
Пример #4
0
        /// <summary>
        /// Remove all connections from an output connector
        /// </summary>
        /// <param name="positionObject"></param>
        public void ClearOutput(object positionObject)
        {
            AudioNodeOutput tempOutput = GetOutputAtPosition((Vector2)positionObject);

            for (int i = 0; i < this.selectedEvent.EditorNodes.Count; i++)
            {
                AudioNode tempNode = this.selectedEvent.EditorNodes[i];
                if (tempNode.Input != null)
                {
                    tempNode.Input.RemoveConnection(tempOutput);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Perform necessary actions for the a mouse button being released this frame
        /// </summary>
        /// <param name="e">The input event handled by Unity</param>
        private void HandleMouseUp(Event e)
        {
            this.leftButtonDown = false;
            if (this.rightButtonClicked && !this.hasPanned)
            {
                this.selectedNode   = GetNodeAtPosition(e.mousePosition);
                this.selectedOutput = GetOutputAtPosition(e.mousePosition);
                AudioNodeInput tempInput = GetInputAtPosition(e.mousePosition);

                if (tempInput != null)
                {
                    InputContextMenu(e.mousePosition);
                }
                else if (this.selectedOutput != null)
                {
                    OutputContextMenu(e.mousePosition);
                }
                else if (this.selectedNode == null)
                {
                    CanvasContextMenu(e.mousePosition);
                }
                else
                {
                    ModifyNodeContextMenu(e.mousePosition);
                }
            }
            else
            {
                if (this.selectedOutput != null)
                {
                    AudioNodeInput hoverInput = GetInputAtPosition(e.mousePosition);
                    if (hoverInput != null)
                    {
                        hoverInput.AddConnection(this.selectedOutput);
                    }
                }
            }

            this.panGraph           = false;
            this.hasPanned          = false;
            this.selectedOutput     = null;
            this.rightButtonClicked = false;
            this.leftButtonDown     = false;
        }
Пример #6
0
        /// <summary>
        /// EDITOR: Clear an output connection
        /// </summary>
        /// <param name="outputToDelete">Output to disconnect from this input</param>
        public void RemoveConnection(AudioNodeOutput outputToDelete)
        {
            if (outputToDelete == null)
            {
                return;
            }

            List <AudioNodeOutput> updatedNodes = new List <AudioNodeOutput>();

            for (int i = this.connectedNodes.Length - 1; i >= 0; i--)
            {
                AudioNodeOutput tempOutput = this.connectedNodes[i];
                if (tempOutput != outputToDelete)
                {
                    updatedNodes.Add(tempOutput);
                }
            }

            this.connectedNodes = updatedNodes.ToArray();
        }
Пример #7
0
        /// <summary>
        /// EDITOR: Connect a new output to this input
        /// </summary>
        /// <param name="newOutput">The new output to connect</param>
        public void AddConnection(AudioNodeOutput newOutput)
        {
            if (this.forceSingleConnection)
            {
                AudioNodeOutput[] singleOutput = new AudioNodeOutput[1];
                singleOutput[0]     = newOutput;
                this.connectedNodes = singleOutput;
                return;
            }

            for (int i = 0; i < this.connectedNodes.Length; i++)
            {
                if (this.connectedNodes[i] == newOutput)
                {
                    return;
                }
            }

            AudioNodeOutput[] newOutputs = new AudioNodeOutput[this.connectedNodes.Length + 1];
            this.connectedNodes.CopyTo(newOutputs, 0);
            newOutputs[newOutputs.Length - 1] = newOutput;
            this.connectedNodes = newOutputs;
            EditorUtility.SetDirty(this);
        }