This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
public class Pool : MonoBehaviour | |
{ | |
private const int DEFUALT_POOL_SIZE = 100; | |
private static Dictionary<IPoolable, Pool> pools = new Dictionary<IPoolable, Pool>(); | |
public static Pool GetPool(IPoolable prefab) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using UnityEditor; | |
using UnityEngine; | |
public class PoolPreparer : MonoBehaviour | |
{ | |
[SerializeField] | |
GameObject[] prefabs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Initialize(IPoolable poolablePrefab, int initialSize = DEFUALT_POOL_SIZE) | |
{ | |
this.prefab = (poolablePrefab as Component).gameObject; | |
for (int i = 0; i < initialSize; i++) | |
{ | |
var pooledObject = (Instantiate(this.prefab) as GameObject).GetComponent<IPoolable>(); | |
(pooledObject as Component).gameObject.name += " " + i; | |
pooledObject.OnDestroyEvent += () => AddObjectToAvailable(pooledObject); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IPoolable Get() | |
{ | |
lock (this) | |
{ | |
if (objects.Count == 0) | |
{ | |
int amountToGrowPool = Mathf.Max((disabledObjects.Count / 10), 1); | |
Initialize(this.prefab.GetComponent<IPoolable>(), amountToGrowPool); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Pool GetPool(IPoolable prefab) | |
{ | |
if (pools.ContainsKey(prefab)) | |
{ | |
if (pools[prefab] != null) | |
return pools[prefab]; | |
else | |
pools.Remove(prefab); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class Projectile : MonoBehaviour, IPoolable | |
{ | |
private void OnDisable() { OnDestroyEvent(); } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public class InvertedSphere : EditorWindow | |
{ | |
private string st = "1.0"; | |
[MenuItem("GameObject/Create Other/Inverted Sphere...")] | |
public static void ShowWindow() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
using UnityEngine.Video; | |
public class VideoSelection : MonoBehaviour | |
{ | |
[SerializeField] | |
private VideoClip videoClip; | |
private VideoPlayer videoPlayer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class GazeInput : MonoBehaviour | |
{ | |
private Ray ray; | |
private RaycastHit hitInfo; | |
[SerializeField] | |
[Tooltip("The root object of all menu items")] | |
private GameObject menuRoot; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SelectionBase] | |
public class MyClass : MonoBehaviour | |
{ | |
} |