private void OnPreSelectCustomize(ObjectPreSelectCustomizeInfo customizeInfo, List <GameObject> toBeSelected) { if (IgnoreObjectGroups) { List <GameObject> roots = GameObjectEx.GetRoots(toBeSelected); if (roots.Count == 0) { return; } List <GameObject> selectThese = new List <GameObject>(roots.Count * 10); foreach (var root in roots) { selectThese.AddRange(root.GetAllChildrenAndSelf()); } customizeInfo.SelectThese(selectThese); } else { HashSet <GameObject> selectedObjects = new HashSet <GameObject>(); foreach (var gameObj in toBeSelected) { // If this is an object group, ignore it if (RTObjectGroupDb.Get.IsGroup(gameObj)) { continue; } // Now move to the furthest parent up the hierarchy which is not an object group and // select it and all its children. Transform parentTransform = GetFurthestParentNotGroup(gameObj); // Store the parent and all its children var allObjectsInHierarchy = parentTransform.gameObject.GetAllChildrenAndSelf(); foreach (var hierarchyObject in allObjectsInHierarchy) { selectedObjects.Add(hierarchyObject); } } // Select the objects customizeInfo.SelectThese(selectedObjects); } }
private void OnPreDeselectCustomize(ObjectPreDeselectCustomizeInfo customizeInfo, List <GameObject> toBeDeselected) { if (IgnoreObjectGroups) { List <GameObject> roots = GameObjectEx.GetRoots(toBeDeselected); if (roots.Count == 0) { return; } List <GameObject> deselectThese = new List <GameObject>(roots.Count * 10); foreach (var root in roots) { deselectThese.AddRange(root.GetAllChildrenAndSelf()); } customizeInfo.DeselectThese(deselectThese); } else { HashSet <GameObject> deselectedObjects = new HashSet <GameObject>(); foreach (var gameObj in toBeDeselected) { if (RTObjectGroupDb.Get.IsGroup(gameObj)) { continue; } Transform parentTransform = GetFurthestParentNotGroup(gameObj); var allObjectsInHierarchy = parentTransform.gameObject.GetAllChildrenAndSelf(); foreach (var hierarchyObject in allObjectsInHierarchy) { deselectedObjects.Add(hierarchyObject); } } customizeInfo.DeselectThese(deselectedObjects); } }