Exemple #1
0
 private void Awake()
 {
     ObjectPoolCollection[] objectPoolsInScene = FindObjectsOfType <ObjectPoolCollection>();
     foreach (ObjectPoolCollection objPool in objectPoolsInScene)
     {
         if (objPool.poolType == tracerObjectPoolType)
         {
             tracerObjectPool = objPool;
             break;
         }
     }
 }
Exemple #2
0
    void ShowObjectPools()
    {
        if (LargeAddButton(objectPoolsProperty, new GUIContent("Add New Object Pool")))
        {
            objectPool.ObjectPools[objectPool.ObjectPools.Length - 1] = new ObjectPoolCollection(objectPool.PreloadAmount, objectPool.SpawnMore, objectPool.SlowMessage, objectPool.HandleParticles, objectPool.TrackObjects, objectPool.CullExtras, objectPool.CullInterval);
        }

        if (objectPool == null || objectPool.ObjectPools == null)
        {
            return;
        }

        for (int i = 0; i < objectPool.ObjectPools.Length; i++)
        {
            currentPool         = objectPool.ObjectPools[i];
            currentPoolProperty = serializedObject.FindProperty("ObjectPools").GetArrayElementAtIndex(i);

            BeginBox();
            string currentPoolName = currentPool.Prefab != null ? currentPool.Prefab.name : "default";
            if (DeleteFoldOut(objectPoolsProperty, i, currentPoolName.ToGUIContent()))
            {
                break;
            }

            if (currentPoolProperty.isExpanded)
            {
                EditorGUI.indentLevel += 1;

                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("Prefab"), new GUIContent("Prefab", "Reference to the Prefab or GameObject used by this Object Pool."));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("CullExtras"), new GUIContent("Cull Extras", "The default value used when adding objects to the Object Pool."));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("CullInterval"), new GUIContent("Cull Interval", "How often should we look at culling extra objects."));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("ManageParticles"), new GUIContent("Handle Particles", "Should particle systems be appropriately handled when despawning?"));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("PreloadAmount"), new GUIContent("Preload Amount", "The number of objects to preload in an Object Pool."));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("SendMessage"), new GUIContent("Send Message", "Should Unity's SendMessage be used (OnSpawned, WaitToDespawn, OnDespawned)."));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("SpawnMore"), new GUIContent("Spawn More", "Should additional objects be spawned as needed?"));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("TrackObjects"), new GUIContent("Track Objects", "Should objects be tracked when they are spawned?"));
                EditorGUILayout.PropertyField(currentPoolProperty.FindPropertyRelative("DespawnPoolLocation"), new GUIContent("Despawn Pool Location", "Should despawned object be returned to it's pool's origin position?"));
                Separator();

                EditorGUI.indentLevel -= 1;
            }
            EndBox();
        }
    }