/// <summary> /// Sets up the lists for each SwarmItem type. Also creates the parent transform for the active and inactive objects /// </summary> public virtual void Initialize() { // warn the user if no prefabs were set up. There would be no need for a manager without SwarmItems if (itemPrefabs.Length == 0) { Debug.Log("WARNING! No Item Prefabs exists for " + gameObject.name + " -- Errors will occur."); } // make sure all the thresholds and percentages are clamped between 0 and 1.0f foreach (PrefabItem itemPrefab in itemPrefabs) { itemPrefab.inactiveThreshold = Mathf.Clamp01(itemPrefab.inactiveThreshold); itemPrefab.inactivePrunePercentage = Mathf.Clamp01(itemPrefab.inactivePrunePercentage); } // initialize the prefab item lists _prefabItemLists = new PrefabItemLists[itemPrefabs.Length]; for (int i = 0; i < _prefabItemLists.Length; i++) { _prefabItemLists[i] = new PrefabItemLists(); _prefabItemLists[i].inactivePruneTimeLeft = 0; } // create the active objects parent transform _go = new GameObject("Active Items"); _activeParentTransform = _go.transform; _activeParentTransform.parent = this.transform; _activeParentTransform.localPosition = Vector3.zero; _activeParentTransform.localRotation = Quaternion.identity; _activeParentTransform.localScale = Vector3.one; // create the inactive objects parent transform; _go = new GameObject("Inactive Items"); _inactiveParentTransform = _go.transform; _inactiveParentTransform.parent = this.transform; _inactiveParentTransform.localPosition = Vector3.zero; _inactiveParentTransform.localRotation = Quaternion.identity; _inactiveParentTransform.localScale = Vector3.one; }
/// <summary> /// Sets up the lists for each SwarmItem type. Also creates the parent transform for the active and inactive objects /// </summary> public virtual void Initialize() { // warn the user if no prefabs were set up. There would be no need for a manager without SwarmItems if (itemPrefabs.Length == 0) { Debug.Log("WARNING! No Item Prefabs exists for " + gameObject.name + " -- Errors will occur."); } // make sure all the thresholds and percentages are clamped between 0 and 1.0f foreach (PrefabItem itemPrefab in itemPrefabs) { itemPrefab.inactiveThreshold = Mathf.Clamp01(itemPrefab.inactiveThreshold); itemPrefab.inactivePrunePercentage = Mathf.Clamp01(itemPrefab.inactivePrunePercentage); } // initialize the prefab item lists _prefabItemLists = new PrefabItemLists[itemPrefabs.Length]; for (int i=0; i<_prefabItemLists.Length; i++) { _prefabItemLists[i] = new PrefabItemLists(); _prefabItemLists[i].itemCount = 0; _prefabItemLists[i].inactivePruneTimeLeft = 0; } // create the active objects parent transform _go = new GameObject("Active Items"); _activeParentTransform = _go.transform; _activeParentTransform.parent = this.transform; _activeParentTransform.localPosition = Vector3.zero; _activeParentTransform.localRotation = Quaternion.identity; _activeParentTransform.localScale = Vector3.one; // create the inactive objects parent transform; _go = new GameObject("Inactive Items"); _inactiveParentTransform = _go.transform; _inactiveParentTransform.parent = this.transform; _inactiveParentTransform.localPosition = Vector3.zero; _inactiveParentTransform.localRotation = Quaternion.identity; _inactiveParentTransform.localScale = Vector3.one; }