public void Add(FollowMachine followmachine) { if (followmachine != null) { GraphList.Add(followmachine.GetInstanceID()); } followmachine.Editor().OnShow(); }
protected override TreeViewItem BuildRoot() { var followMachines = Object.FindObjectsOfType <FollowMachine>() .OrderBy(fm => fm.transform.GetSiblingIndex()) .ToArray(); var root = new TreeViewItem(0, -1, "Root"); if (followMachines.Length == 0) { root.AddChild(new TreeViewItem { id = 1, displayName = "Follow machine not found!" }); } else { var items = new List <TreeViewItem>(); foreach (var machine in followMachines) { items.Add(new TreeViewItem { id = machine.GetInstanceID(), displayName = machine.name, }); } for (int i = 0; i < followMachines.Length; i++) { FollowMachine parentFollowMachine = null; if (followMachines[i].transform.parent) { parentFollowMachine = followMachines[i].transform.parent.GetComponentInParent <FollowMachine>(); } if (parentFollowMachine == null) { root.AddChild(items[i]); } else { items.Find(item => item.id == parentFollowMachine.GetInstanceID()).AddChild(items[i]); } } } SetupDepthsFromParentsAndChildren(root); return(root); }