public void AddTargetDrawers(IEnumerable <Drawer> drawers, DrawerActionScope scope, bool updateResult) { foreach (var d in drawers) { AddTargetDrawer(d, scope, updateResult); } }
public void SaveState(DrawerActionScope scope) { foreach (var drawer in EnumerateByScope(scope)) { DrawerStates.Set(drawer.HierarchicalName, drawer.CreateState()); } }
public void ResetVisiblity(DrawerActionScope scope, bool bySavedStates = true) { if (scope == DrawerActionScope.Self) { ResetVisibility(bySavedStates); // Avoid heap alloc from EnumerateByScope. } else { foreach (var drawer in EnumerateByScope(scope)) { drawer.ResetVisibility(bySavedStates); } } }
/// <summary> /// Enumerate related drawers of current instance by specific scope. /// </summary> /// <param name="scope">Scope that indicates what drawers to enumerate.</param> /// <returns>An enumerable collection that enumerate all drawers refered by specific scope.</returns> public IEnumerable <Drawer> EnumerateByScope(DrawerActionScope scope) { switch (scope) { case DrawerActionScope.Self: return(this.ToEnumerable()); case DrawerActionScope.Children: return(Children); case DrawerActionScope.ChildrenInHierarchy: return(ChildrenInHierarchy); case DrawerActionScope.SelfAndChildren: return(this.ToEnumerable().Concat(Children)); case DrawerActionScope.SelfAndChildrenInHierarchy: return(this.ToEnumerable().Concat(ChildrenInHierarchy)); default: throw new ArgumentOutOfRangeException("scope", scope, null); } }
public void AddTargetDrawer(Drawer drawer, DrawerActionScope scope, bool updateResult) { Ensure.Argument.NotNull(drawer, "drawer"); AddTargetDrawersWithIteratingCheck(drawer.EnumerateByScope(scope), updateResult); }
public Drawer[] ListByScope(DrawerActionScope scope) { return(EnumerateByScope(scope).ToArray()); }
public static void LogDrawerHierarchy(Drawer drawer, DrawerActionScope scope) { Debug.Log(StringUtil.Join(drawer.EnumerateByScope(scope), d => d.HierarchicalName, "\n")); }
public static void LogDrawerHierarchy(IEnumerable <Drawer> drawers, DrawerActionScope scope) { var list = drawers.SelectMany(d => d.EnumerateByScope(scope)); Debug.Log(StringUtil.Join(list, d => d.HierarchicalName, "\n")); }