public void Add(Transform child, CanvasBranch branch) { if (branch == CanvasBranch.None) { child.SetParent(TopLayer.BranchRoot, false); } else { GetBranch(branch).Add(child, CanvasBranch.None); } }
public CanvasElement GetBranch(CanvasBranch branch) { if (branch == CanvasBranch.None) { return this; } if (!Branches.ContainsKey(branch)) { Branches[branch] = GetNewLayer(branch.ToString()); var branchList = Branches.ToList(); branchList.Add(new KeyValuePair<CanvasBranch, CanvasElement>(CanvasBranch.None, TopLayer)); var orderedBranches = from kv in branchList orderby (int)kv.Key descending select kv; foreach (var kv in orderedBranches) { kv.Value.BranchRoot.transform.SetAsFirstSibling(); } } return Branches[branch]; }
public GameObject AddNew(GameObject prefab, CanvasBranch branch = CanvasBranch.Default) { var instance = Instantiate<GameObject>(prefab); Add(instance.transform, branch); return instance; }
public void PushLayer(CanvasBranch branch = CanvasBranch.None) { if (branch == CanvasBranch.None) { root.PushLayer(); } else { root.TopLayer.GetBranch(branch).PushLayer(); } }
public void Add(Transform ui, CanvasBranch branch = CanvasBranch.Default) { if (branch == CanvasBranch.Root) { ui.SetParent(transform, false); } else { root.TopLayer.Add(ui, branch); } }