public void DrawConnectLine(RuntimePort A, RuntimePort B) { CachePool.I().GetObject("Prefabs/Line", (obj) => { obj.transform.SetParent(RuntimeGraph.I().LineGroup, false); RuntimeLine line = obj.GetComponent <RuntimeLine>(); line.Draw(A, B); }); }
public void GetInputer(string Type, string Name, object Value) { CachePool.I().GetObject("Prefabs/Content/" + Type, (obj) => { obj.transform.SetParent(ContentParent, false); Inputer inputer = obj.GetComponent <Inputer>(); inputer.SetLabel(Name); inputer.SetValue(Value); BaseInputer.Add(Name, inputer); }); }
void NextMenu(MenuItem item) { for (int i = 0; i < transform.childCount; i++) { //TODO: Change to put object if (transform.GetChild(i).name != "Label") { Destroy(transform.GetChild(i).gameObject); } } if (item.father != null) { CachePool.I().GetObject("Prefabs/Context/BackButton", (obj) => { obj.transform.SetParent(transform, false); RightClickMenuItem rcItem = obj.GetComponent <RightClickMenuItem>(); MenuItem next = item; rcItem.AddAction(() => { Label.text = Label.text.Substring(0, Label.text.Length - new StringBuilder("/").Append(item.name).ToString().Length); NextMenu(next.father); }); }); } for (int i = 0; i < item.SubItems.Count; i++) { CachePool.I().GetObject("Prefabs/Context/ContextButton", (obj) => { obj.transform.SetParent(transform, false); RightClickMenuItem rcItem = obj.GetComponent <RightClickMenuItem>(); rcItem.SetLabel(Item.SubItems[i].name); MenuItem nextItem = Item.SubItems[i]; MenuItem cur = item; rcItem.AddAction(() => { nextItem.father = cur; Label.text += new StringBuilder("/").Append(nextItem.name).ToString(); NextMenu(nextItem); }); }); } foreach (var key in item.ActualItem.Keys) { CachePool.I().GetObject("Prefabs/Context/ActualButton", (obj) => { obj.transform.SetParent(transform, false); RightClickMenuItem rcItem = obj.GetComponent <RightClickMenuItem>(); rcItem.SetLabel(key); rcItem.AddAction(item.ActualItem[key]); }); } }
IEnumerator IE_Load() { //Load All Nodes for (int i = 0; i < graph.Node.Count; i++) { CachePool.I().GetObject("Prefabs/NodeBase", (obj) => { obj.transform.SetParent(NodeGroup, false); RuntimeNode rnode = obj.GetComponent <RuntimeNode>(); rnode.Load(graph.Node[i]); Nodes.Add(rnode); }); } //Connect All Ports for (int i = 0; i < Nodes.Count; i++) { Nodes[i].Connect(); } yield return(null); Save(); }
public void Load(NodeBase node = null) { //Set current base Base = node != null ? node : Base; //Set position transform.localPosition = new Vector3(Base.NodePosition.x, Base.NodePosition.y); //Set label Label.text = Base.Label; #region Set Input ports for (int i = 0; i < Base.InputPorts.Count; i++) { CachePool.I().GetObject("Prefabs/InputPort", (obj) => { obj.transform.SetParent(InputParent, false); RuntimePort rp = obj.GetComponent <RuntimePort>(); rp.Load(Base.InputPorts[i]); InputPorts.Add(rp); RuntimeGraph.I().Ports.Add(rp.Base.UID, rp); }); } #endregion #region Set Output ports for (int i = 0; i < Base.OutputPorts.Count; i++) { CachePool.I().GetObject("Prefabs/OutputPort", (obj) => { obj.transform.SetParent(OutputParent, false); RuntimePort rp = obj.GetComponent <RuntimePort>(); rp.Load(Base.OutputPorts[i]); OutputPorts.Add(rp); RuntimeGraph.I().Ports.Add(rp.Base.UID, rp); }); } #endregion #region Set Content System.Type t = Base.GetType(); FieldInfo[] info = t.GetFields(); int ContentCounter = 0; int FieldsCount = 0; for (int i = 0; i < info.Length; i++) { HideFieldAttribute hideAtt = (HideFieldAttribute)info[i].GetCustomAttribute(typeof(HideFieldAttribute), false); if (hideAtt != null) { continue; } FieldsCount++; if (!Base.ShowedPropertiesList.Contains(info[i].Name)) { continue; } ContentCounter++; System.Type CurType = info[i].FieldType; string HumanReadableName = info[i].Name.Replace("_", " "); if (CurType == RuntimeGraph.I().stringType) { TextAreaAttribute att = (TextAreaAttribute)info[i].GetCustomAttribute(typeof(TextAreaAttribute), false); if (att == null) { GetInputer("String", HumanReadableName, info[i].GetValue(Base)); } else { GetInputer("StringMultiline", HumanReadableName, info[i].GetValue(Base)); } } else if (CurType == RuntimeGraph.I().intType) { RangeAttribute att = (RangeAttribute)info[i].GetCustomAttribute(typeof(RangeAttribute), false); if (att == null) { GetInputer("Int", HumanReadableName, info[i].GetValue(Base)); } else { CachePool.I().GetObject("Prefabs/Content/Int_Range", (obj) => { obj.transform.SetParent(ContentParent, false); IntRange inputer = obj.GetComponent <IntRange>(); inputer.SetLabel(HumanReadableName); inputer.SetValue(info[i].GetValue(Base)); inputer.SetRange(att.min, att.max); BaseInputer.Add(HumanReadableName, inputer); }); } } else if (CurType == RuntimeGraph.I().floatType) { RangeAttribute att = (RangeAttribute)info[i].GetCustomAttribute(typeof(RangeAttribute), false); if (att == null) { GetInputer("Decimal", HumanReadableName, info[i].GetValue(Base)); } else { CachePool.I().GetObject("Prefabs/Content/Decimal_Range", (obj) => { obj.transform.SetParent(ContentParent, false); DecimalRange inputer = obj.GetComponent <DecimalRange>(); inputer.SetLabel(HumanReadableName); inputer.SetValue(info[i].GetValue(Base)); inputer.SetRange(att.min, att.max); BaseInputer.Add(HumanReadableName, inputer); }); } } else if (CurType == RuntimeGraph.I().Vector2Type) { GetInputer("Vector2", HumanReadableName, info[i].GetValue(Base)); } else if (CurType == RuntimeGraph.I().Vector3Type) { GetInputer("Vector3", HumanReadableName, info[i].GetValue(Base)); } else if (CurType == RuntimeGraph.I().Vector4Type) { GetInputer("Vector4", HumanReadableName, info[i].GetValue(Base)); } else if (CurType == RuntimeGraph.I().QuaternionType) { GetInputer("Vector4", HumanReadableName, info[i].GetValue(Base)); } else if (CurType == RuntimeGraph.I().boolType) { GetInputer("Toggle", HumanReadableName, info[i].GetValue(Base)); } else if (CurType == RuntimeGraph.I().enumType) { GetInputer("Dropdown", HumanReadableName, info[i].GetValue(Base)); CachePool.I().GetObject("Prefabs/Content/Dropdown", (obj) => { obj.transform.SetParent(ContentParent, false); DropdownMenu inputer = obj.GetComponent <DropdownMenu>(); object temp = info[i].GetValue(Base); inputer.SetEnum(info[i].FieldType); inputer.SetLabel(HumanReadableName); inputer.SetValue(temp); BaseInputer.Add(HumanReadableName, inputer); }); } } #endregion #region Set Add Button if (ContentCounter < FieldsCount) { CachePool.I().GetObject("Prefabs/Content/AddButton", (obj) => { obj.transform.SetParent(ContentParent, false); }); } #endregion }