Exemplo n.º 1
0
    public void drawConnectionCurves()
    {
        StoryEditorManager sem = FindObjectOfType <StoryEditorManager>();

        foreach (GameObject element in nodeParts) //for every element in this pages nodeparts
        {
            ElementNodeGraphicManager engm = element.GetComponent <ElementNodeGraphicManager>();
            int connectionKey = 0;                                              //this will increment with every processed selection connector so that it will apply each connection to a selection connector
            foreach (GameObject selectionConnector in engm.selectionConnectors) //for every selection connector in this element
            {
                //get the connection
                ConnectionInfo            connection = engm.associatedElement.GetComponent <PageElementEventTrigger>().connections[connectionKey++];
                BezierCurve4PointRenderer curve      = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefabs/StoryEditor/CurveRenderer.prefab")
                                                                              , contentWindow).GetComponent <BezierCurve4PointRenderer>();

                selectionConnector.GetComponentInChildren <ManipulateNodeLines>().curve = curve;
                curve.originConnector = selectionConnector.GetComponentInChildren <ManipulateNodeLines>().gameObject;

                foreach (GameObject graphic in sem.pageGraphics)
                {
                    PageNodeGraphicManager pngm = graphic.GetComponent <PageNodeGraphicManager>();
                    if (connection.connectedPage.Equals(pngm.page))                                                                                //if the connected page matches this page
                    {
                        if (connection.connectedElement != null)                                                                                   //if its connected to an element node and not a page node
                        {
                            foreach (GameObject otherElement in pngm.nodeParts)                                                                    //check all the elements in the origin page
                            {
                                if (connection.connectedElement.Equals(otherElement.GetComponent <ElementNodeGraphicManager>().associatedElement)) //when one matches thats the origin connector
                                {
                                    ReceiveNodeLines rnl = otherElement.GetComponentInChildren <ReceiveNodeLines>();
                                    curve.receivingConnector = rnl.gameObject;
                                    rnl.curves.Add(curve);
                                }
                            }
                        }
                        else
                        {
                            //The first ReceiveNodeLines should be the PageNodeConnector receiver since it his highest in hierarchy
                            ReceiveNodeLines rnl = pngm.GetComponentInChildren <ReceiveNodeLines>();
                            curve.receivingConnector = rnl.gameObject;
                            rnl.curves.Add(curve);
                        }
                    }
                }
                curve.setAction(connection.action);
                curve.snapEndpointsToConnectors();
            }
        }
    }
Exemplo n.º 2
0
 private void Awake()
 {
     sem = (StoryEditorManager)target;
 }