コード例 #1
0
    public Mapper_Node PlaceObjAsMain(Mapper_Node_Main mainNode)
    {
        Mapper_NodeConnector outputConnector = null;
        Mapper_Node          childNode       = null;

        foreach (Mapper_NodeConnector con in mainNode.connectors)
        {
            if (con.conType == ConType.cParent)
            {
                outputConnector = con;
            }
        }

        childNode = outputConnector.childLines[0].childNode.node;

        Object     prefab = Resources.Load(objPath + childNode.nodeName);
        Vector3    pos    = new Vector3((float)mainNode.mainInfo.posInWorldX, (float)mainNode.mainInfo.posInWorldY, (float)mainNode.mainInfo.posInWorldZ);
        GameObject go     = (GameObject)Instantiate(prefab, pos, Quaternion.identity, folder.transform);

        go.name = childNode.nodeName;
        go.transform.Rotate(0, Random.Range(0.0f, 360.0f), 0, Space.World);

        childNode.seInfo.isPlaced = true;
        childNode.seInfo.nodeGO   = go;

        return(childNode);
    }
コード例 #2
0
    public void CheckConnection(Mapper_Editor editor)
    {
        if (conType == ConType.cParent)
        {
            DrawConnection(editor);
        }

        if (Clicked())
        {
            Mapper_NodeConnector.nodeWaitingForConnection = this;
            Event.current.Use();
        }

        if (!ConnectionInProgress())
        {
            if (Released())
            {
                TryMakeConnection();
            }
            return;
        }

        if (Event.current.type == EventType.Repaint && Mapper_NodeConnector.nodeWaitingForConnection != null)
        {
            Color c = Color.black;

            bool    input = (conType == ConType.cChild);
            Vector2 start = input ? GetConnectionPoint() : MousePos();
            Vector2 end   = input ? MousePos() : GetConnectionPoint();;

            DrawTempLine(start, end);
        }
    }
コード例 #3
0
    public void LinkTo(Mapper_NodeConnector otherNode, ConnectionInfo connectionInfo = null)
    {
        if (conType == ConType.cChild)
        {
            otherNode.LinkTo(this);
            return;
        }

        Mapper_NodeConnectionLine temp = ScriptableObject.CreateInstance <Mapper_NodeConnectionLine>().Initialize(this, otherNode, node.editor, connectionInfo);

        childLines.Add(temp);
        otherNode.parentLines.Add(temp);
    }
コード例 #4
0
    public Mapper_NodeConnectionLine Initialize(Mapper_NodeConnector parentNode, Mapper_NodeConnector childNode, Mapper_Editor editor, ConnectionInfo connectionInfo = null)
    {
        this.editor     = editor;
        this.parentNode = parentNode;
        this.childNode  = childNode;

        if (connectionInfo == null)
        {
            this.connectionInfo = new ConnectionInfo();
        }
        else
        {
            this.connectionInfo = connectionInfo;
        }

        return(this);
    }
コード例 #5
0
    public void ToPlaceObj(Mapper_Node objNode)
    {
        Mapper_NodeConnector outputConnector = null;
        Mapper_NodeConnector inputConnector  = null;
        Mapper_Node          childNode       = null;

        foreach (Mapper_NodeConnector con in objNode.connectors)
        {
            if (con.conType == ConType.cParent)
            {
                outputConnector = con;
            }
            if (con.conType == ConType.cChild)
            {
                inputConnector = con;
            }
        }

        for (int i = 0; i < outputConnector.childLines.Count; i++)
        {
            childNode = outputConnector.childLines[i].childNode.node;
            if (objNode.seInfo.isPlaced == true && childNode.seInfo.isPlaced == false)
            {
                PlaceObj(objNode, childNode, outputConnector.childLines[i]);
                ToPlaceObj(childNode);
            }
        }

        if (objNode is Mapper_Node_Object)
        {
            for (int i = 0; i < inputConnector.parentLines.Count; i++)
            {
                childNode = inputConnector.parentLines[i].parentNode.node;
                if (objNode.seInfo.isPlaced == true && childNode.seInfo.isPlaced == false)
                {
                    PlaceObj(objNode, childNode, inputConnector.parentLines[i], true);
                    ToPlaceObj(childNode);
                }
            }
        }
    }
コード例 #6
0
    void UpdateCameraPanning()
    {
        if ((Event.current.rawType == EventType.MouseUp) && (Event.current.button == 0))
        {
            panCamera = false;
        }

        bool insideNodeView = MouseInsideNodeView(true);
        bool dragging       = (Event.current.type == EventType.MouseDrag && panCamera);
        bool connecting     = Mapper_NodeConnector.IsConnecting();

        if (connecting)
        {
            Vector2 mousePosInNodeViewScreenSpace = ViewSpaceToScreenSpace(Event.current.mousePosition) - Vector2.right * editor.separatorLeft.rect.xMax;

            float dragPanMargin = 32f;
            float panSpeed      = 0.2f;
            float leftMag       = Mathf.Clamp(-mousePosInNodeViewScreenSpace.x + dragPanMargin, 0f, dragPanMargin);
            float rightMag      = Mathf.Clamp(mousePosInNodeViewScreenSpace.x - rect.width + dragPanMargin, 0f, dragPanMargin);
            float topMag        = Mathf.Clamp(-mousePosInNodeViewScreenSpace.y + dragPanMargin, 0f, dragPanMargin);
            float bottomMag     = Mathf.Clamp(mousePosInNodeViewScreenSpace.y - rect.height + dragPanMargin, 0f, dragPanMargin);
            cameraPos += new Vector2(rightMag - leftMag, bottomMag - topMag) * panSpeed;
        }

        bool doingSomethingElse = connecting;
        bool dragInside         = dragging && insideNodeView;

        if (dragInside && !doingSomethingElse)
        {
            cameraPos -= Event.current.delta;
            SnapCamera();

            Event.current.Use();
        }

        if ((Event.current.rawType == EventType.MouseUp) && (Event.current.button == 0))
        {
            panCamera = true;
        }
    }
コード例 #7
0
    public void TryMakeConnection()
    {
        if (Mapper_NodeConnector.nodeWaitingForConnection == null)
        {
            return;
        }

        if (nodeWaitingForConnection == this)
        {
            Mapper_NodeConnector.nodeWaitingForConnection = null;
            return;
        }

        if (nodeWaitingForConnection.conType == this.conType)
        {
            Mapper_NodeConnector.nodeWaitingForConnection = null;
            return;
        }
        LinkTo(Mapper_NodeConnector.nodeWaitingForConnection);

        Mapper_NodeConnector.nodeWaitingForConnection = null;
    }
コード例 #8
0
    public static void LinkNodes(Mapper_Node parentNode, Mapper_Node childNode, ConnectionInfo conInfo = null)
    {
        Mapper_NodeConnector parentOutputNode = null;
        Mapper_NodeConnector childInputNode   = null;

        foreach (Mapper_NodeConnector nodeCon in parentNode.connectors)
        {
            if (nodeCon.conType == ConType.cParent)
            {
                parentOutputNode = nodeCon;
            }
        }

        foreach (Mapper_NodeConnector nodeCon in childNode.connectors)
        {
            if (nodeCon.conType == ConType.cChild)
            {
                childInputNode = nodeCon;
            }
        }

        parentOutputNode.LinkTo(childInputNode, conInfo);
    }