public void DeleteInterfaceNode(btInterfaceNode _node) { bool removed = this.nodeList.Remove(_node); if (removed == false) { Debug.LogError("Interface node " + _node + " not found in node list."); return; } btInterfaceInnerNode innerNode = _node as btInterfaceInnerNode; if (innerNode != null) { innerNode.RemoveChildrenConnections(); } _node.RemoveParent(); if (btUIManager.instance.currentNode == _node) { btUIManager.instance.HideNodeDetailPanel(); } GameObject.Destroy(_node.gameObject); }
/// <summary> /// Recursively builds the tree using the input interface node /// Children nodes are created and populated using the children of the interface node, then they recurse this function if able /// </summary> /// <param name="_interfaceNode"> The input interface node</param> public void AddChildNodes_r(btInterfaceNode _interfaceNode) { btInterfaceInnerNode innerInterfaceNode = _interfaceNode as btInterfaceInnerNode; if (innerInterfaceNode == null) { return; } foreach (btInterfaceConnection connection in innerInterfaceNode.childConnectors) { btInterfaceNode interfaceChild = connection.child; btFunctionNode functionChild = interfaceChild.CreateFunctionNode(); functionChild.variable = interfaceChild.variable; functionChild.interfaceNode = interfaceChild; interfaceChild.functionNode = functionChild; this.children.Add(functionChild); btFunctionInnerNode innerFunctionNode = functionChild as btFunctionInnerNode; if (innerFunctionNode != null) { innerFunctionNode.AddChildNodes_r(interfaceChild); } } }
public bool HasNodeInChildTree(btInterfaceNode _node) { if (this.GetHasThisChild(_node) == true) { return(true); } foreach (btInterfaceConnection connection in this.childConnectors) { btInterfaceInnerNode childInnerNode = connection.child as btInterfaceInnerNode; if (childInnerNode != null && childInnerNode.HasNodeInChildTree(_node) == true) { return(true); } } return(false); }
public virtual void Update() { //this.glowTexture.enabled = this.isBeingDragged; if (this.isBeingDragged == true) { if (this.parentConnector != null) { this.parentConnector.parent.invalidChildIndices = true; } } btInterfaceInnerNode innerNode = this as btInterfaceInnerNode; if (innerNode != null && innerNode.invalidChildIndices == true) { innerNode.ResetChildIndices(); } this.dotTexture.enabled = (this.parentConnector != null); }
public GameObject CreateInterfaceNode(INODE_TYPE _nodeType) { GameObject nodeTemplate = GameObject.Instantiate(this.nodeTemplatePrefab) as GameObject; nodeTemplate.transform.parent = this.gameObject.transform; nodeTemplate.transform.localScale = new Vector3(1, 1, 1); nodeTemplate.transform.localPosition = new Vector3(0, 0, 0); btInterfaceNodeTemplate templateScript = nodeTemplate.GetComponent <btInterfaceNodeTemplate>(); btInterfaceNode nodeScript = nodeTemplate.AddComponent(btInterfaceTreeManager.GetInterfaceNodeType(_nodeType)) as btInterfaceNode; this.nodeList.Add(nodeScript); nodeScript.nodeType = _nodeType; nodeScript.dragScript = nodeScript.GetComponent <UIDragObject>(); btAreaLimiter areaLimiter = nodeTemplate.GetComponent <btAreaLimiter>(); areaLimiter.limitTransform = this.edittingArea; btInterfaceInnerNode innerNodeScript = nodeScript as btInterfaceInnerNode; btInterfaceRootNode rootNodeScript = nodeScript as btInterfaceRootNode; GameObject infoButton = this.AddComponentToNode(nodeTemplate, this.infoButtonPrefab, templateScript.infoButtonPlaceholder); btInterfaceNodeInfo infoScript = infoButton.GetComponent <btInterfaceNodeInfo>(); infoScript.attachedNode = nodeScript; nodeScript.glowTexture = templateScript.glowTexture; nodeScript.dotTexture = templateScript.dotTexture; if (innerNodeScript != null) { GameObject connectorObj = this.AddComponentToNode(nodeTemplate, this.connectorPrefab, templateScript.connectorPlaceholder); btInterfaceConnector connectorScript = connectorObj.GetComponent <btInterfaceConnector>(); connectorScript.attachedNode = innerNodeScript; btAreaLimiter dragLimiter = connectorScript.dragWidget.GetComponent <btAreaLimiter>(); dragLimiter.limitTransform = this.edittingArea; innerNodeScript.Connector = connectorScript; } if (nodeScript.CanHaveParent()) { GameObject receiverObj = this.AddComponentToNode(nodeTemplate, this.receiverPrefab, templateScript.receiverPlaceholder); btInterfaceReceiver receiverScript = receiverObj.GetComponent <btInterfaceReceiver>(); receiverScript.attachedNode = nodeScript; nodeScript.receiver = receiverScript; } if (rootNodeScript == null) { GameObject deleteButtonObj = this.AddComponentToNode(nodeTemplate, this.deleteButtonPrefab, templateScript.deleteButtonPlaceholder); btInterfaceDeleteNode deleteScript = deleteButtonObj.GetComponent <btInterfaceDeleteNode>(); deleteScript.attachedNode = nodeScript; nodeScript.deleteButton = deleteScript; GameObject indexDisplayObj = this.AddComponentToNode(nodeTemplate, this.indexDisplayPrefab, templateScript.indexDisplayPlaceholder); nodeScript.indexDisplay = indexDisplayObj.GetComponent <btInterfaceIndexDisplay>(); } else { areaLimiter.enabled = false; } string materialPath = nodeScript.GetIconMaterialPath(); Object iconResource = Resources.Load(materialPath); if (iconResource == null) { Debug.LogError("Cannot find material with path \"" + materialPath + "\""); return(nodeTemplate); } Material iconMaterial = iconResource as Material; if (iconMaterial == null) { Debug.LogError("Resource \"" + iconResource.name + "\" at path \"" + materialPath + "\" cannot be converted into a meterial."); return(nodeTemplate); } Material backgroundMaterial = null; if (nodeScript as btInterfaceInnerNode != null) { backgroundMaterial = this.innerNodeMaterial; } else if (nodeScript as btInterfaceActionNode != null) { backgroundMaterial = this.actionNodeMaterial; } else if (nodeScript as btInterfaceTestNode != null) { backgroundMaterial = this.testNodeMaterial; } templateScript.iconTexture.material = iconMaterial; string nodeLabel = nodeScript.GetDisplayLabel(); nodeTemplate.name = nodeLabel + "InterfaceNode" + this.nodeList.Count; templateScript.backgroundTexture.material = backgroundMaterial; // Clean up template object placeholders GameObject.Destroy(templateScript.connectorPlaceholder.gameObject); GameObject.Destroy(templateScript.deleteButtonPlaceholder.gameObject); GameObject.Destroy(templateScript.indexDisplayPlaceholder.gameObject); GameObject.Destroy(templateScript.receiverPlaceholder.gameObject); return(nodeTemplate); }