Пример #1
0
    public void buildFromPage(Page content)
    {
        page      = content;
        nodeParts = new List <GameObject>();
        // float heightOfRect = titleHeight + footerHeight; //Starts at height of title since that will always be the minimum height of title
        foreach (GameObject element in content.getElements())
        {
            GameObject body = GameObject.Instantiate(elementNodePrefab, this.transform);
            body.GetComponentInChildren <InputField>().text = element.name;
            body.name = "ElementNode_" + element.name;
            try
            {
                body.GetComponentInChildren <Image>().sprite = element.GetComponent <Image>().sprite;
            }
            catch (Exception) { }//in case this element doesn't have a sprite
            body.GetComponent <ElementNodeGraphicManager>().associatedElement = element;


            //add dropdowns and set them to reflect their actions
            int numberOfDropdowns          = element.GetComponent <PageElementEventTrigger>().connections.Count;
            ElementNodeGraphicManager engm = body.GetComponent <ElementNodeGraphicManager>();
            engm.addSelectionConnectors(numberOfDropdowns);
            for (int i = 0; i < numberOfDropdowns; i++)
            {
                ConnectionInfo connection             = element.GetComponent <PageElementEventTrigger>().connections[i];
                PageElementEventTrigger.Action action = connection.action;
                Dropdown dropdown = engm.selectionConnectors[i].GetComponentInChildren <Dropdown>();
                if (dropdown != null)
                {
                    if (action == PageElementEventTrigger.Action.Change)
                    {
                        dropdown.value = 0;
                    }
                    else if (action == PageElementEventTrigger.Action.Show)
                    {
                        dropdown.value = 1;
                    }
                    else if (action == PageElementEventTrigger.Action.Hide)
                    {
                        dropdown.value = 2;
                    }
                }
                else
                {
                    Debug.Log("No dropdown found in selection connector");
                }

                //set the connection key in ManipulateNodeLines for this selection connector
                dropdown.GetComponentInParent <SelectionConnectorManager>().GetComponentInChildren <ManipulateNodeLines>()
                .connectionKey = connection.connectionKey;
            }
            nodeParts.Add(body);
        }
        drawElementNodes();

        GetComponentInChildren <InputField>().text = page.getName(); //set title of node graphic to page name
        name = "NodeGraphic_" + page.getName();
        this.GetComponent <RectTransform>().anchoredPosition = content.nodeGraphicLocation;
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        ElementNodeGraphicManager engm = (ElementNodeGraphicManager)target;

        if (GUILayout.Button("Add selection connector"))
        {
            engm.addSelectionConnectors(1);
        }
    }