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; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); ElementNodeGraphicManager engm = (ElementNodeGraphicManager)target; if (GUILayout.Button("Add selection connector")) { engm.addSelectionConnectors(1); } }
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(); } } }
public new void OnPointerClick(PointerEventData data) { ElementNodeGraphicManager engm = GetComponentInParent <ElementNodeGraphicManager>(); GameObject selectionConnector = GetComponentInParent <SelectionConnectorManager>().gameObject; engm.selectionConnectors.Remove(selectionConnector); engm.drawSelectionConnectors(); GetComponentInParent <PageNodeGraphicManager>().drawElementNodes(); try { GetComponentInParent <SelectionConnectorManager>().GetComponentInChildren <ManipulateNodeLines>().curve.breakLink(); } catch (NullReferenceException) { } //Distribute new element indexes to connections in peet since ones with greater indexes than the one we are deleting will shift down GameObject.Destroy(selectionConnector); }