public new void OnDrop(PointerEventData data)
    {
        currentCurve = ManipulateNodeLines.lastDraggedCurve.GetComponent <BezierCurve4PointRenderer>();
        Debug.Log("Action: " + currentCurve.action + "Receiver Type" + connectionReceiverType);
        if (currentCurve.action == PageElementEventTrigger.Action.Change)
        {
            //Check if theres already a Change connection since each page element can only have one change
            foreach (ConnectionInfo connection in currentCurve.originConnector.GetComponentInParent <ElementNodeGraphicManager>().
                     associatedElement.GetComponent <PageElementEventTrigger>().connections.Values)
            {
                if (connection.action == PageElementEventTrigger.Action.Change)
                {
                    Debug.Log("Already has a change connection, cannot have more than one per page element");
                    currentCurve.breakLink();
                    return;
                }
            }

            if (connectionReceiverType == ConnectionReceiverType.Element)
            {
                Debug.Log("Wrong receiver type, please connect to the page receiver");
                //Give the user some kind of feedback
                currentCurve.breakLink();
            }
            else
            {
                giveConnectionReferences();
            }
        }
        else
        {
            if (connectionReceiverType == ConnectionReceiverType.Page)
            {
                Debug.Log("Wrong Receiver type, please connect to the element receiver");
                //give user feedback
                currentCurve.breakLink();
            }
            else
            {
                giveConnectionReferences();
            }
        }
    }
    private PageElementEventTrigger peet; //The peet this element is associated with

    void Start()
    {
        peet          = GetComponentInParent <ElementNodeGraphicManager>().associatedElement.GetComponent <PageElementEventTrigger>();
        connectionKey = GetComponentInChildren <ManipulateNodeLines>().connectionKey;
        dropdown      = GetComponentInChildren <Dropdown>();

        dropdown.onValueChanged.AddListener(delegate
        {
            //Check to see if the change is still valid to the connector it is connected to (Can call hide and show both on an element but not on a page)
            //If valid, change action and color of curve, otherwise break the link
            try
            {
                connectionKey = GetComponentInChildren <ManipulateNodeLines>().connectionKey;
                PageElementEventTrigger.Action selection = getDropdownSelection();
                if (selection == PageElementEventTrigger.Action.Change || selection == PageElementEventTrigger.Action.Edit) //These can only be connected to page connectors
                {
                    BezierCurve4PointRenderer curve = GetComponentInChildren <ManipulateNodeLines>().curve;
                    if (peet.connections[connectionKey].connectedElement != null) //if the connected receiver is from an Element then it cannot be page changed to
                    {
                        Debug.Log("Breaking link because trying to Change to Element");
                        curve.breakLink();
                    }
                    else
                    {
                        Debug.Log("Changing old selection to Change");
                        peet.connections[connectionKey].action = selection;
                        curve.setAction(selection);
                    }
                }
                else
                {
                    BezierCurve4PointRenderer curve = GetComponentInChildren <ManipulateNodeLines>().curve;
                    if (peet.connections[connectionKey].connectedElement == null) //if the connected receiver is from an page then it cannot have an element function applied
                    {
                        Debug.Log("Breaking link because trying to " + selection + " to Page");
                        curve.breakLink();
                    }
                    else
                    {
                        Debug.Log("Changing old selection to " + selection);
                        peet.connections[connectionKey].action = selection;
                        curve.setAction(selection);
                    }
                }
            }
            catch (KeyNotFoundException) { }   //If key wasn't found then there wasn't a connection already made
            catch (NullReferenceException) { } //if curve wasn't found then there wasnt a connection already made
        });
    }
Beispiel #3
0
    public new void OnBeginDrag(PointerEventData data)
    {
        //clear any references to next page or next element since previous curve is replaced so the link has been broken
        PageElementEventTrigger peet = GetComponentInParent <ElementNodeGraphicManager>().associatedElement.GetComponent <PageElementEventTrigger>();

        //peet.AddConnection(null, null, PageElementEventTrigger.Action.None); //shouldn't need this with current implementation
        if (curve != null)
        {
            curve.breakLink();
        }
        curve = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefabs/StoryEditor/CurveRenderer.prefab")
                                       , contentWindow).GetComponent <BezierCurve4PointRenderer>();

        curve.setAction(GetComponentInParent <SelectionConnectorManager>().getDropdownSelection());

        curve.originConnector = gameObject; //Give reference to this connector's game object to the curve
        lastDraggedCurve      = curve.gameObject;
        dragging = true;
    }