コード例 #1
0
ファイル: NodePrefab.cs プロジェクト: khill25/Carbon-editor
    public void SetupConnections()
    {
        foreach (int childId in childrenIds)
        {
            // Find the child nodes
            GameObject childObject = ObjectManager.instance.getGameObjectNodeWithNodeId(childId);
            NodePrefab child       = childObject.GetComponent <NodePrefab>();
            this.childNodes.Add(child);

            SFLineRenderer line = Instantiate <SFLineRenderer> (lineRendererPrefab);
            line.gameObject.SetActive(true);

            child.lineRenderers.Add(this.nodeId, line);
            lineRenderers.Add(child.nodeId, line);

            line.addBezierPath(this, child);
        }

        foreach (int parentId in parentIds)
        {
            // Find the child nodes
            GameObject parentObject = ObjectManager.instance.getGameObjectNodeWithNodeId(parentId);
            NodePrefab parent       = parentObject.GetComponent <NodePrefab>();
            this.connectedFromNodes.Add(parent);
        }
    }
コード例 #2
0
ファイル: NodePrefab.cs プロジェクト: khill25/Carbon-editor
    protected void doConnectionDragging()
    {
        updateCurrentBezierCurve();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            // Disable the line renderer
            //currentlyDraggingLine
            currentlyDraggingLine.gameObject.SetActive(false);
            GameObject.Destroy(currentlyDraggingLine.gameObject);
            currentlyDraggingLine = null;

            nextState = NodeState.DraggingConnectionEnding;
            shouldTransitionToNextState = true;
        }
        else if (Input.GetMouseButtonDown(0))
        {
            // Raycast and find the node it clicked on
            // if it's a valid node then get it
            // set the destination
            // and add this into it's list of
            // connected nodes

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Abs(Camera.main.transform.position.z) + 20))
            {
                NodePrefab destination = hit.collider.GetComponent <NodePrefab> ();
                connectedToDestinationNode(destination);
            }
        }
    }
コード例 #3
0
ファイル: NodePrefab.cs プロジェクト: khill25/Carbon-editor
    public void addNewConnectionButtonPressed()
    {
        // Select destination node
        this.currentlyDraggingLine = Instantiate <SFLineRenderer> (lineRendererPrefab);
        this.currentlyDraggingLine.gameObject.SetActive(true);

        Vector3 mousePos = Input.mousePosition;

        mousePos.z = Mathf.Abs(Camera.main.transform.position.z);
        mousePos   = Camera.main.ScreenToWorldPoint(mousePos);
        this.currentlyDraggingLine.addBeginingBezierPathPoints(gameObject.transform.position, mousePos);

        nextState = NodeState.DraggingConnection;
        shouldTransitionToNextState = true;
    }
コード例 #4
0
    public void AddNewConnection()
    {
        this.tempLineRenderer = Instantiate <SFLineRenderer> (linePrefab);
        this.tempLineRenderer.gameObject.SetActive(true);

        Vector3 mousePos = WorldMousePosition();

        mousePos.z = lineZOffset;
        Vector3 position = gameObject.transform.position;

        position.z = lineZOffset;
        this.tempLineRenderer.addBeginingBezierPathPoints(position, mousePos);

        ChangeState(EditorNodeState.DraggingConnectionStarted);
    }
コード例 #5
0
    protected void DoConnectionDragging()
    {
        updateCurrentBezierCurve();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            // Disable the line renderer
            //currentlyDraggingLine
            tempLineRenderer.gameObject.SetActive(false);
            GameObject.Destroy(tempLineRenderer.gameObject);
            tempLineRenderer = null;

            ChangeState(EditorNodeState.DraggingConnectionEnded);
        }
        else if (Input.GetMouseButtonDown(0))
        {
            // Raycast and find the node it clicked on
            // if it's a valid node then get it
            // set the destination
            // and add this into it's list of
            // connected nodes

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Abs(Camera.main.transform.position.z) + 20))
            {
                INodeBase destination = hit.collider.GetComponent <INodeBase> ();
                if (destination is EditorNodeBase)
                {
                    FinishNewConnection(destination as EditorNodeBase);
                }
                else
                {
                    Debug.Log("Clicked node was not an editor node.");
                }
            }
        }
    }