public void InitializeVisualElement(VisualContainer _vContainer, VarPass _nodeConnection) { vContainer = _vContainer; varPass = _nodeConnection; //Get Names for our variables if (varPass.dataDirection == DataDirection.OutcomeData) { //adjust name position if(vContainer.node.outConNames.ContainsKey(varPass.varType)){ if(vContainer.node.outConNames[varPass.varType].Count > varPass.num){ elName.text = vContainer.node.outConNames[varPass.varType][varPass.num]; } } } if (varPass.dataDirection == DataDirection.IncomeData) { //adjust name position elName.alignment = TextAnchor.MiddleLeft; elName.rectTransform.anchoredPosition = new Vector2(elName.rectTransform.anchoredPosition.x * -1, elName.rectTransform.anchoredPosition.y); if(vContainer.node.inConNames.ContainsKey(varPass.varType)){ if(vContainer.node.inConNames[varPass.varType].Count > varPass.num){ elName.text = vContainer.node.inConNames[varPass.varType][varPass.num]; } } } }
public void InitializeConnectionUI(VisualElement _visElement, VisualElement _otherVisElement) { visElement = _visElement; otherVisElement = _otherVisElement; varPass = visElement.varPass; beginTrans = visElement.transform; endTrans = otherVisElement.transform; }
//break connection between nodes' variables. Uses input variables as input var comes from one outputvar whille one // output var can pass to multiply input vars public void BreakConnection(VarPass _con) { if (_con.dataDirection == DataDirection.IncomeData) { if(_con.oppositeConnections.Count > 0){ int index = _con.oppositeConnections[0].oppositeConnections.IndexOf(_con); _con.oppositeConnections[0].oppositeConnections[index] = null; GameObject go = elementsVisualsDict[_con.oppositeConnections[0]].conUIs[index].gameObject; elementsVisualsDict[_con].conUIs.Clear(); _con.oppositeConnections[0] = null; Destroy(go); } } }
public bool BindConnections(VarPass outNode, VarPass inNode, VarType outType, VarType inType, int outNum, int inNum) { if (outType == VarType.IdWeightList) { Debug.Log("Binding..."); IOutputList<IdWeight> outIdWeightList = outNode.node as IOutputList<IdWeight>; if(outIdWeightList == null) return false; Debug.Log("got output interface..."); if(inNode.varType == VarType.IdWeightVar){ return false; } if (inNode.varType == VarType.IdWeightList){ Debug.Log("got list node..." + inNode.node.GetType().ToString()); IInputList<IdWeight> inIdWeightList = inNode.node as IInputList<IdWeight>; if(inIdWeightList == null) return false; inIdWeightList.inputList = outIdWeightList.outputList; if (outNode.oppositeConnections.Count == 0) outNode.oppositeConnections.Add(inNode); else{ outNode.oppositeConnections.Clear(); outNode.oppositeConnections.Add(inNode); } return true; } if (inNode.varType == VarType.IdWeightNestedList){ Debug.Log("got nested list node..." + inNode.node.GetType().ToString()); IInputMultyList<IdWeight> inIdWeightMultyList = inNode.node as IInputMultyList<IdWeight>; if(inIdWeightMultyList == null) return false; Debug.Log("got input Nested list interface..."); inIdWeightMultyList.inputLists[inNum] = outIdWeightList.outputList; if (outNode.oppositeConnections.Count == 0){ outNode.oppositeConnections.Add(inNode); inNode.oppositeConnections.Add(outNode); Debug.Log("Adding to empty new opposite connection"); } else{ outNode.oppositeConnections.Clear(); outNode.oppositeConnections.Add(inNode); inNode.oppositeConnections.Add(outNode); Debug.Log("Replacing new opposite connection"); } return true; } return false; } return false; }