private CheckState GetCheckState(ILayer layer) { bool hasUncheckedChild = false; bool hasCheckedChild = false; foreach (ILayer subLayer in layer.Layers) { CheckState subCheckState = GetCheckState(subLayer); switch (subCheckState) { case CheckState.Checked: hasCheckedChild = true; break; case CheckState.Unchecked: hasUncheckedChild = true; break; case CheckState.Indeterminate: hasCheckedChild = true; hasUncheckedChild = true; break; } } if (!hasCheckedChild || !hasUncheckedChild) { foreach (IGameObject gameObject in layer.GetGameObjects()) { IVisible iVisible = gameObject.As <IVisible>(); if (iVisible != null) { if (iVisible.Visible) { hasCheckedChild = true; } else { hasUncheckedChild = true; } } } } if (hasCheckedChild && !hasUncheckedChild) { return(CheckState.Checked); } if (hasUncheckedChild && !hasCheckedChild) { return(CheckState.Unchecked); } return(CheckState.Indeterminate); }
private void PropagateVisible(ILayer layer, bool visible) { // Recursive call to update all sub-layers foreach (ILayer subLayer in layer.Layers) { PropagateVisible(subLayer, visible); } // Set visibility for all GameObjects foreach (IGameObject gameObject in layer.GetGameObjects()) { IVisible iVisible = gameObject.As <IVisible>(); if (iVisible != null) { iVisible.Visible = visible; } } }
private void PropagateVisible(ILayer layer, bool visible) { // Recursive call to update all sub-layers foreach (ILayer subLayer in layer.Layers) PropagateVisible(subLayer, visible); // Set visibility for all GameObjects foreach (IGameObject gameObject in layer.GetGameObjects()) { IVisible iVisible = gameObject.As<IVisible>(); if (iVisible != null) iVisible.Visible = visible; } }
private CheckState GetCheckState(ILayer layer) { bool hasUncheckedChild = false; bool hasCheckedChild = false; foreach (ILayer subLayer in layer.Layers) { CheckState subCheckState = GetCheckState(subLayer); switch (subCheckState) { case CheckState.Checked: hasCheckedChild = true; break; case CheckState.Unchecked: hasUncheckedChild = true; break; case CheckState.Indeterminate: hasCheckedChild = true; hasUncheckedChild = true; break; } } if (!hasCheckedChild || !hasUncheckedChild) { foreach (IGameObject gameObject in layer.GetGameObjects()) { IVisible iVisible = gameObject.As<IVisible>(); if (iVisible != null) { if (iVisible.Visible) hasCheckedChild = true; else hasUncheckedChild = true; } } } if (hasCheckedChild && !hasUncheckedChild) return CheckState.Checked; if (hasUncheckedChild && !hasCheckedChild) return CheckState.Unchecked; return CheckState.Indeterminate; }