Use the following methods to manage the Prefab Groups. Refer to PrefabAndObjectManager.cs for full detials.
Activate a Group
Activating a group will turn on Game Objects and instantiate Prefabs. Depending on your settings, it may also automatically deactivate other groups.
prefabAndObjectManager.ActivateGroup(groupName); // By nameprefabAndObjectManager.ActivateGroup(groupIndex); // By indexprefabAndObjectManager.ActivateGroup(prefabGroup); // By PrefabGroup
Deactivate a Group
Deactivating a group will turn off Game Objects and destroy Prefabs. Depending on your settings, it may also automatically activate a group set as "Default".
prefabAndObjectManager.DeactivateGroup(groupName); // By nameprefabAndObjectManager.DeactivateGroup(groupIndex); // By indexprefabAndObjectManager.DeactivateGroup(prefabGroup); // By PrefabGroup// Deactivate all groups of a specific typeprefabAndObjectManager.DeactivateGroupsOfType(groupType);
Check if a Group is Active
As groups may share objects, it is possible that a group is not active, fully active, or partially active, where some, but not all, of the objects are active.
// By indexif (prefabAndObjectManager.GroupIsActive(groupIndex) ==0){Debug.Log("Group is not active");}// By PrefabGroupif (prefabAndObjectManager.GroupIsActive(prefabGroup) ==1){Debug.Log("Group is partially active");}// By nameif (prefabAndObjectManager.GroupIsActive(groupName) ==2){Debug.Log("Group is fully active");}// 0 = Not active// 1 = Partially active (some of the objects are active, but not all)// 2 = Active
Getting a List<string> of Types
If you need to obtain a list of all Types, perhaps for UI, this method will come in handy.
// Cached versionforeach(var type inprefabAndObjectManager.GroupTypeNames(){Debug.Log($"Type: {type}");}// You can also use this method, though it will do more computation each time it is called.foreach(var type inprefabAndObjectManager.GetGroupTypeNames()){Debug.Log($"Type: {type}");}
Getting a List<PrefabGroup> with All Groups of a Type
If you need to obtain a list of all Types, perhaps for UI, this method will come in handy.
foreach(var type inprefabAndObjectManager.GetGroupsOfType(groupType)){Debug.Log($"Type: {type}");}
Get a Prefab Group
This will return a PrefabGroup object, for whatever purposes you see fit.
var prefabGroup =prefabAndObjectManager.GetPrefabGroup(groupName);
Activate a Random PrefabGroup
There are options for a single type, one from all types, or just one random group from a random type.
// Random from a specific typeprefabAndObjectManager.ActivateRandomGroup(groupType);// One random from all typesprefabAndObjectManager.ActivateRandomAllGroups();// One random group from one random typeprefabAndObjectManager.ActivateRandomGroupType();