Example #1
0
 public void Add(Transform child, CanvasBranch branch)
 {
     if (branch == CanvasBranch.None) {
         child.SetParent(TopLayer.BranchRoot, false);
     } else {
         GetBranch(branch).Add(child, CanvasBranch.None);
     }
 }
Example #2
0
    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];
    }
Example #3
0
 public GameObject AddNew(GameObject prefab, CanvasBranch branch = CanvasBranch.Default)
 {
     var instance = Instantiate<GameObject>(prefab);
     Add(instance.transform, branch);
     return instance;
 }
Example #4
0
 public void PushLayer(CanvasBranch branch = CanvasBranch.None)
 {
     if (branch == CanvasBranch.None) {
         root.PushLayer();
     } else {
         root.TopLayer.GetBranch(branch).PushLayer();
     }
 }
Example #5
0
 public void Add(Transform ui, CanvasBranch branch = CanvasBranch.Default)
 {
     if (branch == CanvasBranch.Root) {
         ui.SetParent(transform, false);
     } else {
         root.TopLayer.Add(ui, branch);
     }
 }