From 4f39d9baeafd8619307c5141b3a93cc737ee2834 Mon Sep 17 00:00:00 2001 From: coffee <985942825@qq.com> Date: Sat, 4 Jan 2025 13:39:15 +0800 Subject: [PATCH] RecyclablePool --- .../Core/EasyPool/Core/IRecyclable.cs | 2 +- .../EasyPool/Core/RecyclablePoolConfig.cs | 1 + .../Editor/RecyclableGOPoolKitInspector.cs | 106 ++ .../RecyclableGOPoolKitInspector.cs.meta | 3 + .../Core/EasyPool/RecyclableGOPool.meta | 3 + .../RecyclableGOPool/RecyclableGOPoolKit.cs | 51 + .../RecyclableGOPoolKit.cs.meta | 3 + .../RecyclableGOPoolManagerBase.cs | 230 ++++ .../RecyclableGOPoolManagerBase.cs.meta | 3 + .../RecyclableGameObjectPool.cs | 49 + .../RecyclableGameObjectPool.cs.meta | 3 + .../RecyclableMonoBehaviour.cs | 88 ++ .../RecyclableMonoBehaviour.cs.meta | 3 + .../RecyclableGOPool/RecyclablePoolBase.cs | 387 ++++++ .../RecyclablePoolBase.cs.meta | 3 + .../EasyPool/SimpleGOPool/SimpleGOPoolKit.cs | 8 +- .../SimpleGOPool/SimpleGameObjectPool.cs | 131 +- .../Demo/EasyPoolKit/RecyclableGOPool.meta | 8 + .../RecyclableGOPool/Button.prefab | 274 +++++ .../RecyclableGOPool/Button.prefab.meta | 7 + .../RecyclableGOPool/ImageButton.cs | 33 + .../RecyclableGOPool/ImageButton.cs.meta | 3 + .../RecyclableGOPool/RecyclableGOPool.unity | 1082 +++++++++++++++++ .../RecyclableGOPool.unity.meta | 7 + .../RecyclableGOPoolManager.cs | 56 + .../RecyclableGOPoolManager.cs.meta | 2 + 26 files changed, 2471 insertions(+), 75 deletions(-) create mode 100644 Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs create mode 100644 Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs.meta create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool.meta create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs.meta create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs.meta create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs.meta create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs.meta create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs create mode 100644 Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs.meta create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool.meta create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab.meta create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs.meta create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity.meta create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs create mode 100644 Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs.meta diff --git a/Assets/Unity-Tools/Core/EasyPool/Core/IRecyclable.cs b/Assets/Unity-Tools/Core/EasyPool/Core/IRecyclable.cs index e9af4a6..097a413 100644 --- a/Assets/Unity-Tools/Core/EasyPool/Core/IRecyclable.cs +++ b/Assets/Unity-Tools/Core/EasyPool/Core/IRecyclable.cs @@ -14,7 +14,7 @@ void OnObjectInit(); - void OnObjectDeInit(); + void OnObjectDestroyInit(); void OnObjectSpawn(); diff --git a/Assets/Unity-Tools/Core/EasyPool/Core/RecyclablePoolConfig.cs b/Assets/Unity-Tools/Core/EasyPool/Core/RecyclablePoolConfig.cs index e438bb3..971d283 100644 --- a/Assets/Unity-Tools/Core/EasyPool/Core/RecyclablePoolConfig.cs +++ b/Assets/Unity-Tools/Core/EasyPool/Core/RecyclablePoolConfig.cs @@ -14,6 +14,7 @@ namespace Tools.EasyPoolKit public PoolDespawnDestroyType DespawnDestroyType = PoolDespawnDestroyType.Default; public int? MaxDespawnCount = null; public PoolClearType ClearType = PoolClearType.Default; + /// 自动回收时间 public float? AutoClearTime = null; public bool IsIgnoreTimeScale = false; public object[] ExtraArgs = Array.Empty(); diff --git a/Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs b/Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs new file mode 100644 index 0000000..277da6e --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace Tools.EasyPoolKit.Editor +{ + [CustomEditor(typeof(RecyclableGOPoolKit))] + public class RecyclableGOPoolKitInspector : UnityEditor.Editor + { + private readonly HashSet _poolIdsSet = new HashSet(); + + public override void OnInspectorGUI() + { + if (!EditorApplication.isPlaying) + { + EditorGUILayout.HelpBox("Available only on runtime.", MessageType.Info); + return; + } + + var poolMgr = target as RecyclableGOPoolKit; + + if (poolMgr) + { + EditorGUILayout.LabelField("RecyclableGOPoolManager"); + + var poolsInfo = poolMgr.GetPoolsInfo(); + + EditorGUILayout.LabelField("GameObject Pool Count", poolsInfo.Count.ToString()); + + for (int i = 0; i < poolsInfo.Count; i++) + { + var poolInfo = poolsInfo[i]; + DrawGameObjectPool(poolInfo); + } + } + + Repaint(); + } + + private void DrawGameObjectPool(RecyclablePoolInfo poolInfo) + { + var ifLastOpened = _poolIdsSet.Contains(poolInfo.PoolId); + var ifCurOpened = EditorGUILayout.Foldout(ifLastOpened, poolInfo.PoolId); + + if (ifCurOpened != ifLastOpened) + { + if (ifCurOpened) + { + _poolIdsSet.Add(poolInfo.PoolId); + } + else + { + _poolIdsSet.Remove(poolInfo.PoolId); + } + } + + if (ifCurOpened) + { + EditorGUILayout.BeginVertical("box"); + { + EditorGUILayout.LabelField("PoolId", poolInfo.PoolId); + EditorGUILayout.LabelField("ReferenceType", poolInfo.ReferenceType.ToString()); + EditorGUILayout.LabelField("InitCreateCount", poolInfo.InitCreateCount.HasValue ? poolInfo.InitCreateCount.Value.ToString() : "-"); + EditorGUILayout.LabelField("ReachMaxLimitType", poolInfo.ReachMaxLimitType.ToString()); + if (poolInfo.ReachMaxLimitType != PoolReachMaxLimitType.Default) + { + EditorGUILayout.LabelField("MaxSpawnCount", poolInfo.MaxSpawnCount.HasValue ? poolInfo.MaxSpawnCount.Value.ToString() : "-"); + } + EditorGUILayout.LabelField("DespawnDestroyType", poolInfo.DespawnDestroyType.ToString()); + if (poolInfo.DespawnDestroyType == PoolDespawnDestroyType.DestroyToLimit) + { + EditorGUILayout.LabelField("MaxDespawnCount", poolInfo.MaxDespawnCount.HasValue ? poolInfo.MaxDespawnCount.Value.ToString() : "-"); + } + + EditorGUILayout.LabelField("ClearType", poolInfo.ClearType.ToString()); + EditorGUILayout.LabelField("AutoClearTime", poolInfo.AutoClearTime.ToString()); + EditorGUILayout.LabelField("IfIgnoreTimeScale", poolInfo.IsIgnoreTimeScale.ToString()); + EditorGUILayout.LabelField("CachedObjectCount", poolInfo.CachedObjectCount.ToString()); + EditorGUILayout.LabelField("UsedObjectCount", poolInfo.UsedObjectCount.ToString()); + EditorGUILayout.LabelField("TotalObjectCount", poolInfo.TotalObjectCount.ToString()); + + if (GUILayout.Button("ClearUnusedObjects(Safe)")) + { + if (poolInfo.ExtraInfo is RecyclableGameObjectPool pool) + { + pool.ClearUnusedObjects(); + } + } + + if (GUILayout.Button("ClearPool(Unsafe)")) + { + if (poolInfo.ExtraInfo is RecyclableGameObjectPool pool) + { + pool.ClearAll(); + } + } + + //TODO Draw all Objects + } + EditorGUILayout.EndVertical(); + + EditorGUILayout.Separator(); + } + } + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs.meta b/Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs.meta new file mode 100644 index 0000000..a4b259a --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/Editor/RecyclableGOPoolKitInspector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4f91df83af2a4b1783596dc115062a57 +timeCreated: 1735968672 \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool.meta b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool.meta new file mode 100644 index 0000000..d658fe4 --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1b4c6592766748e9850e7f96f3242d3b +timeCreated: 1735963479 \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs new file mode 100644 index 0000000..72cf33e --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs @@ -0,0 +1,51 @@ +using System; +using NUnit.Framework; +using UnityEngine; + +namespace Tools.EasyPoolKit +{ + public class RecyclableGOPoolKit : RecyclableGOPoolManagerBase + { + public static RecyclableGOPoolKit Instance + { + get + { + if (_instance == null) + { + var poolRoot = new GameObject("RecyclableGOPoolKit"); + var cachedRoot = new GameObject("CachedRoot"); + cachedRoot.transform.SetParent(poolRoot.transform, false); + cachedRoot.gameObject.SetActive(false); + _instance = poolRoot.AddComponent(); + _instance.CachedRoot = cachedRoot.transform; + DontDestroyOnLoad(_instance.gameObject); + } + return _instance; + } + } + private static RecyclableGOPoolKit _instance; + + private void Awake() + { + if (_instance != null) + { + Debug.LogError("EasyPoolKit == Don't attach RecyclableGOPoolManager on any object, use SimpleGOPoolManager.Instance instead!"); + Destroy(gameObject); + } + } + + public override RecyclablePoolConfig GetDefaultPrefabPoolConfig(string poolPrefix, GameObject prefabAsset, Func spawnFunc) + { + Assert.IsNotNull(prefabAsset); + var poolConfig = new RecyclablePoolConfig() + { + ObjectType = RecycleObjectType.RecyclableGameObject, + ReferenceType = typeof(GameObject), + PoolId = $"RecyclableGOPool_{poolPrefix ?? string.Empty}_{prefabAsset.GetInstanceID()}", + SpawnFunc = spawnFunc, + }; + + return poolConfig; + } + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs.meta b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs.meta new file mode 100644 index 0000000..ddad69e --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolKit.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8cff55e0843e4bd0875e328d0b7216d5 +timeCreated: 1735965986 \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs new file mode 100644 index 0000000..02af353 --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Assertions; + +namespace Tools.EasyPoolKit +{ + public abstract class RecyclableGOPoolManagerBase : MonoBehaviour + { + public string PoolPrefix = string.Empty; + + /// 缓存根节点 + protected Transform CachedRoot; + + /// key: 预制体的HashID, value: 对应的预制体 + private Dictionary _prefabTemplates = new Dictionary(); + + /// key: 预制体的HashID, value: 对应的对象池 + private Dictionary _gameObjPools = new Dictionary(); + + /// key: 激活的物体实例的HashID, value: 对应的预制体的HashID + private List _poolInfoList = new List(); + public List GetPoolsInfo() => _poolInfoList; + + private bool _ifAppQuit = false; + + /// 检测是否已有对应的对象池 + public bool IfPoolValid(int prefabHash) => _prefabTemplates.ContainsKey(prefabHash) && _gameObjPools.ContainsKey(prefabHash); + + private void Update() + { + foreach (var poolPair in _gameObjPools) + { + var pool = poolPair.Value; + var deltaTime = pool.IsIgnoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime; + pool.OnPoolUpdate(deltaTime); + } + } + + private void OnApplicationQuit() + { + _ifAppQuit = true; + } + + private void OnDestroy() + { + if (!_ifAppQuit) + { + ClearAllPools(true); + } + } + + + public RecyclableGameObjectPool RegisterPrefab(GameObject prefabAsset, RecyclablePoolConfig config = null) + { + Assert.IsNotNull(prefabAsset); + + var prefabHash = prefabAsset.GetInstanceID(); + +#if EASY_POOL_DEBUG + if (_gameObjPools.ContainsKey(prefabHash) || _prefabTemplates.ContainsKey(prefabHash)) + { + Debug.LogError($"EasyPoolKit == RegisterPrefab {prefabAsset.name} but already registered"); + return null; + } +#endif + + if (config == null) + { + config = GetDefaultPrefabPoolConfig(PoolPrefix, prefabAsset, null); + } + + if (config.SpawnFunc == null) + { + config.SpawnFunc = () => DefaultCreateObjectFunc(prefabHash); + } + + if (config.ExtraArgs == null || config.ExtraArgs.Length == 0) + { + config.ExtraArgs = new object[] { CachedRoot }; + } + + _prefabTemplates[prefabHash] = prefabAsset; + var newPool = new RecyclableGameObjectPool(config); + _gameObjPools[prefabHash] = newPool; + _poolInfoList.Add(newPool.GetPoolInfoReadOnly()); + + return newPool; + } + + public bool UnRegisterPrefab(int prefabHash) + { + _prefabTemplates.Remove(prefabHash); + + if (_gameObjPools.TryGetValue(prefabHash, out var pool)) + { + pool.ClearAll(); + _poolInfoList.Remove(pool.GetPoolInfoReadOnly()); + _gameObjPools.Remove(prefabHash); + + return true; + } + + return false; + } + + + public RecyclableMonoBehaviour SimpleSpawn(GameObject prefabTemplate) + { + if (prefabTemplate == null) + { + return null; + } + + var prefabHash = prefabTemplate.GetInstanceID(); + + if (!_gameObjPools.TryGetValue(prefabHash, out var pool)) + { + pool = RegisterPrefab(prefabTemplate); + } + + return pool.SpawnObject(); + } + + public T SimpleSpawn(GameObject prefabTemplate) where T :RecyclableMonoBehaviour + { + return SimpleSpawn(prefabTemplate) as T; + } + + public bool TrySpawn(int prefabHash, out RecyclableMonoBehaviour recyclableObj) + { + recyclableObj = null; + if (_gameObjPools.TryGetValue(prefabHash, out var pool)) + { + recyclableObj = pool.SpawnObject(); + } + + return recyclableObj != null; + } + + public bool TrySpawn(int prefabHash, out T recyclableObj) where T :RecyclableMonoBehaviour + { + recyclableObj = null; + if (TrySpawn(prefabHash, out var newObj)) + { + recyclableObj = newObj as T; + return true; + } + + return false; + } + + public bool Despawn(RecyclableMonoBehaviour recyclableObj) + { + Assert.IsNotNull(recyclableObj); + return recyclableObj.DespawnSelf(); + } + + public bool ClearPoolByAssetHash(int prefabHash, bool onlyClearUnused = false) + { + if (_gameObjPools.TryGetValue(prefabHash, out var pool)) + { + if (onlyClearUnused) + { + pool.ClearUnusedObjects(); + return true; + } + else + { + pool.ClearAll(); + return true; + } + } + + return false; + } + + public void ClearAllUnusedObjects() + { + foreach (var poolPair in _gameObjPools) + { + poolPair.Value.ClearUnusedObjects(); + } + } + + public void ClearAllPools(bool ifDestroy) + { + foreach (var pool in _gameObjPools) + { + pool.Value.ClearAll(); + } + + if (ifDestroy) + { + if (CachedRoot) + { + for (int i = CachedRoot.childCount - 1; i >= 0; i--) + { + var child = CachedRoot.GetChild(i).gameObject; + Destroy(child); + } + } + + _prefabTemplates.Clear(); + _poolInfoList.Clear(); + _gameObjPools.Clear(); + } + } + + private RecyclableMonoBehaviour DefaultCreateObjectFunc(int prefabHash) + { + if (_prefabTemplates.TryGetValue(prefabHash, out var prefabAsset)) + { + if (prefabAsset != null) + { + var gameObj = Instantiate(prefabAsset); + var recyclableObj = gameObj.GetOrCreateRecyclableMono(); + recyclableObj.PrefabHash = prefabHash; + return recyclableObj; + } + } + + Debug.LogError($"EasyPoolKit == Cannot create object: {prefabHash}"); + return null; + } + + public abstract RecyclablePoolConfig GetDefaultPrefabPoolConfig(string poolPrefix, GameObject prefabAsset, + Func spawnFunc); + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs.meta b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs.meta new file mode 100644 index 0000000..de232a0 --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGOPoolManagerBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8cde1003a7854925ac58c691ed66bdf9 +timeCreated: 1735966230 \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs new file mode 100644 index 0000000..24577ae --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs @@ -0,0 +1,49 @@ +using UnityEngine; + +namespace Tools.EasyPoolKit +{ + public class RecyclableGameObjectPool : RecyclablePoolBase + { + private Transform _cachedRoot; + + public RecyclableGameObjectPool(RecyclablePoolConfig config) : base(config) { } + + protected override void OnInitByParams(object[] args) + { + var extraArgs = args; + + if (extraArgs != null && extraArgs.Length > 0 && extraArgs[0] is Transform root) + { + _cachedRoot = root; + } + else + { + Debug.LogError("EasyPoolKit == Create RecyclableMonoPool should input the root Transform in extraArgs[0]"); + } + } + + protected override void OnObjectInit(RecyclableMonoBehaviour usedObj) + { + usedObj.Pool = this; + usedObj.PoolId = PoolId; + } + + protected override void OnObjectEnqueue(RecyclableMonoBehaviour usedObj) + { + usedObj.transform.SetParent(_cachedRoot, true); + } + + protected override void OnObjectDequeue(RecyclableMonoBehaviour usedObj) + { + usedObj.transform.SetParent(null, true); + } + + protected override void OnObjectDestoryInit(RecyclableMonoBehaviour usedObj) + { + if (usedObj) + { + Object.Destroy(usedObj.gameObject); + } + } + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs.meta b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs.meta new file mode 100644 index 0000000..4c38bc1 --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableGameObjectPool.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6ab2cfde92374470825bf4ff3b0ac5a3 +timeCreated: 1735964092 \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs new file mode 100644 index 0000000..401ae15 --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs @@ -0,0 +1,88 @@ +using UnityEngine; +using UnityEngine.Assertions; + +namespace Tools.EasyPoolKit +{ + public class RecyclableMonoBehaviour : MonoBehaviour, IRecyclable + { + public bool EnableMessage = false; + + public RecyclableGameObjectPool Pool { get; set; } + + public static readonly string MessageOnInit = "OnObjectInit"; + public static readonly string MessageOnDeInit = "OnObjectDeInit"; + public static readonly string MessageOnSpawn = "OnObjectSpawn"; + public static readonly string MessageOnDespawn = "OnObjectDespawn"; + + public RecycleObjectType ObjectType => RecycleObjectType.RecyclableGameObject; + public string PoolId { get; set; } + public int ObjectId { get; set; } + public string Name { get => gameObject.name; set => gameObject.name = value; } + public float UsedTime { get; set; } + + public int PrefabHash { get; set; } + + public virtual void OnObjectInit() + { + if (EnableMessage) + { + SendMessage(MessageOnInit, SendMessageOptions.DontRequireReceiver); + } + } + + public virtual void OnObjectDestroyInit() + { + if (EnableMessage) + { + SendMessage(MessageOnDeInit, SendMessageOptions.DontRequireReceiver); + } + } + + public virtual void OnObjectSpawn() + { + if (EnableMessage) + { + SendMessage(MessageOnSpawn, SendMessageOptions.DontRequireReceiver); + } + } + + public virtual void OnObjectDespawn() + { + UsedTime = 0; + PrefabHash = 0; + + if (EnableMessage) + { + SendMessage(MessageOnDespawn, SendMessageOptions.DontRequireReceiver); + } + } + + public virtual void OnObjectUpdate(float deltaTime) + { + UsedTime += deltaTime; + } + + public bool DespawnSelf() + { + return Pool.DespawnObject(this); + } + } + + + public static class RecyclableMonoBehaviourExt + { + public static RecyclableMonoBehaviour GetOrCreateRecyclableMono(this GameObject gameObj, + bool enableMessage = false) + { + Assert.IsNotNull(gameObj); + var recyclableMono = gameObj.GetComponent(); + if (recyclableMono) + { + return recyclableMono; + } + recyclableMono = gameObj.AddComponent(); + recyclableMono.EnableMessage = enableMessage; + return recyclableMono; + } + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs.meta b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs.meta new file mode 100644 index 0000000..d1b72dd --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclableMonoBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cc3dd3e8963f45f198d01d5e6664032e +timeCreated: 1735963499 \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs new file mode 100644 index 0000000..fe32024 --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs @@ -0,0 +1,387 @@ +using System; +using System.Collections.Generic; + +namespace Tools.EasyPoolKit +{ + public abstract class RecyclablePoolBase : IRecyclablePool where T : class, IRecyclable + { + protected Queue CachedQueue { get; private set; } + + protected LinkedList UsedList { get; private set; } + + private int _objectCounter = 0; + + private bool _ifInit = false; + + public RecycleObjectType ObjectType { get; private set;} + public Type ReferenceType { get; private set;} + public string PoolId { get; private set;} + public int? InitCreateCount { get; private set;} + public int? MaxSpawnCount { get; private set;} + public int? MaxDespawnCount { get; private set;} + public float? AutoClearTime { get; private set;} + public Func SpawnFunc { get; set; } + public PoolReachMaxLimitType ReachMaxLimitType { get; private set;} + public PoolDespawnDestroyType DespawnDestroyType { get; private set;} + public PoolClearType ClearType { get; private set;} + public bool IsIgnoreTimeScale { get; private set;} + + public int GetCachedObjectCount() => CachedQueue.Count; + public int GetUsedObjectCount() => UsedList.Count; + public int GetTotalObjectCount() => CachedQueue.Count + UsedList.Count; + + protected readonly RecyclablePoolInfo PoolInfo; + public RecyclablePoolInfo GetPoolInfoReadOnly() => PoolInfo; + + public RecyclablePoolBase(RecyclablePoolConfig config) + { + PoolInfo = InitByConfig(config); + } + + protected virtual RecyclablePoolInfo InitByConfig(RecyclablePoolConfig config) + { + if (_ifInit) + { + throw new Exception("EasyEventPool == Already Init!"); + } + + if (config == null) + { + throw new Exception("EasyEventPool == config is null!"); + } + + ObjectType = config.ObjectType; + ReferenceType = config.ReferenceType; + PoolId = config.PoolId; + SpawnFunc = config.SpawnFunc ?? throw new Exception("EasyEventPool == config.SpawnFunc is null!"); + ReachMaxLimitType = config.ReachMaxLimitType; + DespawnDestroyType = config.DespawnDestroyType; + ClearType = config.ClearType; + InitCreateCount = config.InitCreateCount; + MaxSpawnCount = config.MaxSpawnCount; + MaxDespawnCount = config.MaxDespawnCount; + AutoClearTime = config.AutoClearTime; + IsIgnoreTimeScale = config.IsIgnoreTimeScale; + + var poolInfo = new RecyclablePoolInfo(config, GetCachedObjectCount, GetUsedObjectCount, GetTotalObjectCount, this); + + CachedQueue = MaxSpawnCount.HasValue + ? new Queue(MaxSpawnCount.Value + 1) + : new Queue(); + + UsedList = new LinkedList(); + OnInitByParams(config.ExtraArgs); + InitCachedPool(); + _ifInit = true; + +#if EASY_POOL_DEBUG + //Check if params are valid + if (ReachMaxLimitType == PoolReachMaxLimitType.RejectNull || + ReachMaxLimitType == PoolReachMaxLimitType.RecycleOldest) + { + if (!(MaxSpawnCount.HasValue && MaxSpawnCount.Value > 0)) + { + throw new Exception("MaxSpawnCount.Value should > 0"); + } + } + + if (DespawnDestroyType == PoolDespawnDestroyType.DestroyToLimit) + { + if (!(MaxDespawnCount.HasValue && MaxDespawnCount.Value > 0)) + { + throw new Exception("MaxDespawnCount.Value should > 0"); + } + } + + if (MaxSpawnCount.HasValue && MaxDespawnCount.HasValue) + { + if (!(MaxDespawnCount.Value <= MaxSpawnCount.Value)) + { + throw new Exception("MaxDespawnCount.Value should <= MaxSpawnCount.Value"); + } + } + + if (MaxSpawnCount.HasValue && InitCreateCount.HasValue) + { + if (!(InitCreateCount.Value <= MaxSpawnCount.Value)) + { + throw new Exception("InitCreateCount.Value should <= MaxSpawnCount.Value"); + } + } +#endif + return poolInfo; + } + + public T SpawnObject() + { + T cachedObj = null; + + if (GetCachedObjectCount() > 0) + { + cachedObj = CachedQueue.Dequeue(); + } + else + { + bool ifReachLimit = false; + + if (ReachMaxLimitType != PoolReachMaxLimitType.Default && MaxSpawnCount.HasValue) + { + ifReachLimit = GetTotalObjectCount() >= MaxSpawnCount.Value; + } + + if (!ifReachLimit) + { + cachedObj = CreateObject(); + } + else + { + switch (ReachMaxLimitType) + { + case PoolReachMaxLimitType.RecycleOldest: + cachedObj = RecycleOldestObject(); + break; + case PoolReachMaxLimitType.Default: + //Impossible + case PoolReachMaxLimitType.RejectNull: + default: + //do nothing + break; + } + } + } + + if (cachedObj != null) + { + OnObjectDequeue(cachedObj); + cachedObj.OnObjectSpawn(); + UsedList.AddLast(cachedObj); + } + + return cachedObj; + } + + public bool TrySpawnObject(out T newObj) + { + newObj = SpawnObject(); + return newObj != null; + } + + public bool DespawnObject(T usedObj) + { + if (usedObj == null) + { + return false; + } + + var usedNode = UsedList.Find(usedObj); + + if (usedNode == null) + { + return false; + } + + bool ifReachLimit = false; + + if (DespawnDestroyType == PoolDespawnDestroyType.DestroyToLimit) + { + if (MaxDespawnCount.HasValue && GetTotalObjectCount() > MaxDespawnCount.Value) + { + ifReachLimit = true; + } + } + + UsedList.Remove(usedNode); + usedObj.OnObjectDespawn(); + + if (ifReachLimit) + { + DestroyPoolObject(usedObj); + } + else + { + CachedQueue.Enqueue(usedObj); + OnObjectEnqueue(usedObj); + } + + return true; + } + + public void OnPoolUpdate(float deltaTime) + { + if (UsedList.Count > 0) + { + var beginNode = UsedList.First; + float collectTime = AutoClearTime ?? -1f; + + while (beginNode != null) + { + var currentNode = beginNode; + beginNode = beginNode.Next; + var usedObj = currentNode.Value; + usedObj.OnObjectUpdate(deltaTime); + + if (collectTime > 0 && usedObj.UsedTime >= collectTime) + { + DespawnObject(usedObj); + } + } + } + } + + private void InitCachedPool() + { + if (!InitCreateCount.HasValue) + { + return; + } + + var initCount = InitCreateCount.Value; + + for (int i = 0; i < initCount; i++) + { + var cachedObj = CreateObject(); + CachedQueue.Enqueue(cachedObj); + OnObjectEnqueue(cachedObj); + } + } + + + private T CreateObject() + { + _objectCounter++; + + if (SpawnFunc?.Invoke() is T cachedObj) + { + cachedObj.PoolId = PoolId; + cachedObj.ObjectId = _objectCounter; + +#if EASY_POOL_DEBUG + cachedObj.Name = $"{PoolId}_{cachedObj.ObjectId}"; +#endif + OnObjectInit(cachedObj); + cachedObj.OnObjectInit(); + } +#if EASY_POOL_DEBUG + else + { + throw new Exception($"EasyPoolKit == GenerateObject {PoolId} Should not be null!"); + } +#endif + + return cachedObj; + } + + protected virtual void OnInitByParams(object[] args){} + protected abstract void OnObjectInit(T usedObj); + protected abstract void OnObjectEnqueue(T usedObj); + protected abstract void OnObjectDequeue(T usedObj); + protected abstract void OnObjectDestoryInit(T usedObj); + + private T RecycleOldestObject() + { + var firstNode = UsedList.First; + UsedList.Remove(firstNode); + var oldestObj = firstNode.Value; + + if (oldestObj != null) + { + oldestObj.OnObjectDespawn(); + } + + //As it is a free node, need not to add it to cachedQueue + return oldestObj; + } + + private void DestroyPoolObject(T poolObj) + { + if (poolObj != null) + { + poolObj.OnObjectDestroyInit(); + OnObjectDestoryInit(poolObj); + } + } + + #region Clear + + public void ClearUnusedObjects() + { + foreach (var cachedItem in CachedQueue) + { + DestroyPoolObject(cachedItem); + } + + CachedQueue.Clear(); + } + + public void ClearAll() + { + switch (ClearType) + { + case PoolClearType.Default: + poolClearAll(); + break; + case PoolClearType.ClearToLimit: + poolClearToLimit(); + break; + } + + void poolClearAll() + { + foreach (var cachedItem in CachedQueue) + { + DestroyPoolObject(cachedItem); + } + + CachedQueue.Clear(); + + while (UsedList.Count > 0) + { + var firstNode = UsedList.First; + var firstObj = firstNode.Value; + UsedList.Remove(firstNode); + DestroyPoolObject(firstObj); + } + + UsedList.Clear(); + } + + void poolClearToLimit() + { + if (!InitCreateCount.HasValue) + { + poolClearAll(); + return; + } + + poolClearRetain(); + + int removeCount = GetCachedObjectCount() - InitCreateCount.Value; + + while (removeCount > 0) + { + removeCount--; + var cachedObj = CachedQueue.Dequeue(); + DestroyPoolObject(cachedObj); + } + + // 回收正在使用的物体 + void poolClearRetain() + { + while (UsedList.Count > 0) + { + var firstNode = UsedList.First; + var firstObj = firstNode.Value; + DespawnObject(firstObj); + } + } + } + } + + #endregion + + #region Debug + public string GetDebugConfigInfo() => PoolInfo?.GetDebugConfigInfo() ?? string.Empty; + public string GetDebugRunningInfo() => PoolInfo?.GetDebugRunningInfo() ?? string.Empty; + #endregion + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs.meta b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs.meta new file mode 100644 index 0000000..fc2d980 --- /dev/null +++ b/Assets/Unity-Tools/Core/EasyPool/RecyclableGOPool/RecyclablePoolBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2f64392ce63446c280cd10dee37231e8 +timeCreated: 1735964418 \ No newline at end of file diff --git a/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGOPoolKit.cs b/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGOPoolKit.cs index 0227778..1e2ec6a 100644 --- a/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGOPoolKit.cs +++ b/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGOPoolKit.cs @@ -45,6 +45,8 @@ namespace Tools.EasyPoolKit private bool _ifAppQuit = false; + /// 检测是否已有对应的对象池 + public bool IsPoolValid(int prefabHash) => _prefabTemplates.ContainsKey(prefabHash) && _gameObjPools.ContainsKey(prefabHash); private void Awake() { @@ -78,12 +80,6 @@ namespace Tools.EasyPoolKit ClearAllPools(true); } } - - /// 检测是否已有对应的对象池 - public bool IsPoolValid(int prefabHash) - { - return _prefabTemplates.ContainsKey(prefabHash) && _gameObjPools.ContainsKey(prefabHash); - } public SimpleGameObjectPool RegisterPrefab(GameObject prefabAsset, RecyclablePoolConfig config = null) { diff --git a/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGameObjectPool.cs b/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGameObjectPool.cs index 29b79b7..195b23b 100644 --- a/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGameObjectPool.cs +++ b/Assets/Unity-Tools/Core/EasyPool/SimpleGOPool/SimpleGameObjectPool.cs @@ -32,6 +32,7 @@ namespace Tools.EasyPoolKit public int GetTotalObjectCount() => CachedQueue.Count + UsedList.Count; protected RecyclablePoolInfo PoolInfo; + public RecyclablePoolInfo GetPoolInfoReadOnly() => PoolInfo; public SimpleGameObjectPool(RecyclablePoolConfig config) { @@ -130,7 +131,7 @@ namespace Tools.EasyPoolKit protected virtual void OnObjectInit(GameObject usedObj){ } protected virtual void OnObjectEnqueue(GameObject usedObj) => usedObj.transform.SetParent(_cachedRoot, true); protected virtual void OnObjectDequeue(GameObject usedObj) => usedObj.transform.SetParent(null, true); - protected virtual void OnObjectDeInit(GameObject usedObj) + protected virtual void OnObjectDestroyInit(GameObject usedObj) { if (usedObj) { @@ -279,28 +280,6 @@ namespace Tools.EasyPoolKit return true; } - public void ClearUnusedObjects() - { - foreach (var cachedItem in CachedQueue) - { - DestroyPoolObject(cachedItem); - } - CachedQueue.Clear(); - } - - public void ClearAll() - { - switch (ClearType) - { - case PoolClearType.Default: - PoolClearAll(); - break; - case PoolClearType.ClearToLimit: - PoolClearToLimit(); - break; - } - } - public void OnPoolUpdate(float deltaTime) { if (UsedList.Count > 0) @@ -326,79 +305,95 @@ namespace Tools.EasyPoolKit } } - public RecyclablePoolInfo GetPoolInfoReadOnly() => PoolInfo; - private void DestroyPoolObject(GameObject poolObj) { if (poolObj) { - OnObjectDeInit(poolObj); + OnObjectDestroyInit(poolObj); } } - - private void PoolClearAll() + + #region Clear + + public void ClearUnusedObjects() { foreach (var cachedItem in CachedQueue) { DestroyPoolObject(cachedItem); } CachedQueue.Clear(); + } - while (UsedList.Count > 0) + public void ClearAll() + { + switch (ClearType) { - var firstNode = UsedList.First; - var firstObj = firstNode.Value; - UsedList.Remove(firstNode); - DestroyPoolObject(firstObj); + case PoolClearType.Default: + poolClearAll(); + break; + case PoolClearType.ClearToLimit: + poolClearToLimit(); + break; } - - UsedList.Clear(); - } - private void PoolClearToLimit() - { - if (!InitCreateCount.HasValue) + void poolClearAll() { - PoolClearAll(); - return; - } - - PoolClearRetain(); + foreach (var cachedItem in CachedQueue) + { + DestroyPoolObject(cachedItem); + } + CachedQueue.Clear(); - int removeCount = GetCachedObjectCount() - InitCreateCount.Value; + while (UsedList.Count > 0) + { + var firstNode = UsedList.First; + var firstObj = firstNode.Value; + UsedList.Remove(firstNode); + DestroyPoolObject(firstObj); + } - while (removeCount > 0) - { - removeCount--; - var cachedObj = CachedQueue.Dequeue(); - DestroyPoolObject(cachedObj); + UsedList.Clear(); } - } - /// 回收正在使用的物体 - private void PoolClearRetain() - { - while (UsedList.Count > 0) + void poolClearToLimit() { - var firstNode = UsedList.First; - var firstObj = firstNode.Value; - DespawnObject(firstObj); - } - } + if (!InitCreateCount.HasValue) + { + poolClearAll(); + return; + } + poolClearRetain(); - #region Debug + int removeCount = GetCachedObjectCount() - InitCreateCount.Value; - public string GetDebugConfigInfo() - { - return PoolInfo?.GetDebugConfigInfo() ?? string.Empty; + while (removeCount > 0) + { + removeCount--; + var cachedObj = CachedQueue.Dequeue(); + DestroyPoolObject(cachedObj); + } + + // 回收正在使用的物体 + void poolClearRetain() + { + while (UsedList.Count > 0) + { + var firstNode = UsedList.First; + var firstObj = firstNode.Value; + DespawnObject(firstObj); + } + } + } } + - public string GetDebugRunningInfo() - { - return PoolInfo?.GetDebugRunningInfo() ?? string.Empty; - } + #endregion + + #region Debug + public string GetDebugConfigInfo() => PoolInfo?.GetDebugConfigInfo() ?? string.Empty; + public string GetDebugRunningInfo() => PoolInfo?.GetDebugRunningInfo() ?? string.Empty; #endregion } } \ No newline at end of file diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool.meta b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool.meta new file mode 100644 index 0000000..307c479 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 259a517e8654b99499c0f17a15beb06f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab new file mode 100644 index 0000000..67ea48e --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab @@ -0,0 +1,274 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &212430069314405427 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5249829104186841453} + - component: {fileID: 8202632885764616307} + - component: {fileID: 7186356064517121775} + m_Layer: 5 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5249829104186841453 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 212430069314405427} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6440907175184653233} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8202632885764616307 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 212430069314405427} + m_CullTransparentMesh: 1 +--- !u!114 &7186356064517121775 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 212430069314405427} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Button + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4281479730 + m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 24 + m_fontSizeBase: 24 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_TextWrappingMode: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 0 + m_ActiveFontFeatures: 6e72656b + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_EmojiFallbackSupport: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!1 &5635780241963879440 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6440907175184653233} + - component: {fileID: 3201388121702467737} + - component: {fileID: 4180124986893198757} + - component: {fileID: 54520249064627873} + - component: {fileID: -7838970888251817805} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6440907175184653233 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5635780241963879440} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5249829104186841453} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 91.5, y: -15} + m_SizeDelta: {x: 183, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &3201388121702467737 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5635780241963879440} + m_CullTransparentMesh: 1 +--- !u!114 &4180124986893198757 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5635780241963879440} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &54520249064627873 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5635780241963879440} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 4180124986893198757} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &-7838970888251817805 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5635780241963879440} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 74056c96f6b34045924a42030d0ba1f9, type: 3} + m_Name: + m_EditorClassIdentifier: + EnableMessage: 0 + button: {fileID: 54520249064627873} diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab.meta b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab.meta new file mode 100644 index 0000000..de25ed2 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/Button.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 42fa37d0d62c2c649ad2a46cd6042baa +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs new file mode 100644 index 0000000..5a72904 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs @@ -0,0 +1,33 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace Tools.EasyPoolKit.Demo +{ + public class ImageButton : RecyclableMonoBehaviour + { + [SerializeField] private Button button; + + public override void OnObjectInit() + { + base.OnObjectInit(); + button.onClick.AddListener(OnClick); + } + + public override void OnObjectSpawn() + { + base.OnObjectSpawn(); + Debug.Log($"ImageButton Spawned {name}"); + } + + public override void OnObjectDespawn() + { + base.OnObjectDespawn(); + Debug.Log($"ImageButton Despawn {name}"); + } + + private void OnClick() + { + Debug.Log($"Button Clicked {name}"); + } + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs.meta b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs.meta new file mode 100644 index 0000000..c2c7740 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/ImageButton.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 74056c96f6b34045924a42030d0ba1f9 +timeCreated: 1735967055 \ No newline at end of file diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity new file mode 100644 index 0000000..f800bc8 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity @@ -0,0 +1,1082 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 10 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 13 + m_BakeOnSceneLoad: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 1 + m_PVRFilteringGaussRadiusAO: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &403808052 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 403808053} + - component: {fileID: 403808056} + - component: {fileID: 403808055} + - component: {fileID: 403808054} + m_Layer: 5 + m_Name: Scrollbar Vertical + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &403808053 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 403808052} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1667952184} + m_Father: {fileID: 2082960306} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 20, y: 0} + m_Pivot: {x: 1, y: 1} +--- !u!114 &403808054 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 403808052} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2a4db7a114972834c8e4117be1d82ba3, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1394558250} + m_HandleRect: {fileID: 1394558249} + m_Direction: 2 + m_Value: 0 + m_Size: 1 + m_NumberOfSteps: 0 + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &403808055 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 403808052} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &403808056 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 403808052} + m_CullTransparentMesh: 1 +--- !u!1 &472708483 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 472708486} + - component: {fileID: 472708485} + - component: {fileID: 472708484} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &472708484 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 472708483} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_MoveRepeatDelay: 0.5 + m_MoveRepeatRate: 0.1 + m_XRTrackingOrigin: {fileID: 0} + m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_DeselectOnBackgroundClick: 1 + m_PointerBehavior: 0 + m_CursorLockBehavior: 0 + m_ScrollDeltaPerTick: 6 +--- !u!114 &472708485 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 472708483} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &472708486 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 472708483} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &561813759 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 561813760} + - component: {fileID: 561813761} + m_Layer: 0 + m_Name: Manager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &561813760 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 561813759} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &561813761 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 561813759} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e8aaad6940cad364082cdb3406487a8d, type: 3} + m_Name: + m_EditorClassIdentifier: + buttonPrefab: {fileID: 5635780241963879440, guid: 42fa37d0d62c2c649ad2a46cd6042baa, type: 3} + parent: {fileID: 752094056} +--- !u!1 &752094055 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 752094056} + - component: {fileID: 752094057} + - component: {fileID: 752094058} + m_Layer: 5 + m_Name: Content + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &752094056 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 752094055} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1286346492} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 1} +--- !u!114 &752094057 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 752094055} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 0 + m_Spacing: 0 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 1 + m_ChildControlWidth: 1 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 + m_ReverseArrangement: 0 +--- !u!114 &752094058 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 752094055} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalFit: 0 + m_VerticalFit: 1 +--- !u!1 &871483560 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 871483564} + - component: {fileID: 871483563} + - component: {fileID: 871483562} + - component: {fileID: 871483561} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &871483561 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 871483560} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &871483562 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 871483560} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!223 &871483563 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 871483560} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 + m_AdditionalShaderChannelsFlag: 25 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &871483564 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 871483560} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2082960306} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1279948505 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1279948507} + - component: {fileID: 1279948506} + - component: {fileID: 1279948508} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1279948506 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1279948505} + m_Enabled: 1 + serializedVersion: 11 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ForceVisible: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 + m_LightUnit: 1 + m_LuxAtDistance: 1 + m_EnableSpotReflector: 1 +--- !u!4 &1279948507 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1279948505} + serializedVersion: 2 + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!114 &1279948508 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1279948505} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 3 + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_RenderingLayers: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_ShadowRenderingLayers: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} + m_SoftShadowQuality: 0 +--- !u!1 &1286346491 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1286346492} + - component: {fileID: 1286346495} + - component: {fileID: 1286346494} + - component: {fileID: 1286346493} + m_Layer: 5 + m_Name: Viewport + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1286346492 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1286346491} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 752094056} + m_Father: {fileID: 2082960306} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -17, y: 0} + m_Pivot: {x: 0, y: 1} +--- !u!114 &1286346493 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1286346491} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ShowMaskGraphic: 0 +--- !u!114 &1286346494 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1286346491} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1286346495 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1286346491} + m_CullTransparentMesh: 1 +--- !u!1 &1394558248 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1394558249} + - component: {fileID: 1394558251} + - component: {fileID: 1394558250} + m_Layer: 5 + m_Name: Handle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1394558249 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1394558248} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1667952184} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 20, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1394558250 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1394558248} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1394558251 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1394558248} + m_CullTransparentMesh: 1 +--- !u!1 &1481440583 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1481440586} + - component: {fileID: 1481440585} + - component: {fileID: 1481440584} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1481440584 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1481440583} + m_Enabled: 1 +--- !u!20 &1481440585 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1481440583} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1481440586 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1481440583} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1667952183 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1667952184} + m_Layer: 5 + m_Name: Sliding Area + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1667952184 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1667952183} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1394558249} + m_Father: {fileID: 403808053} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -20, y: -20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &2082960305 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2082960306} + - component: {fileID: 2082960309} + - component: {fileID: 2082960308} + - component: {fileID: 2082960307} + m_Layer: 5 + m_Name: Scroll View + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2082960306 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2082960305} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1286346492} + - {fileID: 403808053} + m_Father: {fileID: 871483564} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -260, y: -323.23364} + m_SizeDelta: {x: 200, y: 200} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2082960307 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2082960305} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Content: {fileID: 752094056} + m_Horizontal: 0 + m_Vertical: 1 + m_MovementType: 1 + m_Elasticity: 0.1 + m_Inertia: 1 + m_DecelerationRate: 0.135 + m_ScrollSensitivity: 1 + m_Viewport: {fileID: 1286346492} + m_HorizontalScrollbar: {fileID: 0} + m_VerticalScrollbar: {fileID: 403808054} + m_HorizontalScrollbarVisibility: 2 + m_VerticalScrollbarVisibility: 0 + m_HorizontalScrollbarSpacing: -3 + m_VerticalScrollbarSpacing: -3 + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &2082960308 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2082960305} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.392} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &2082960309 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2082960305} + m_CullTransparentMesh: 1 +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 1481440586} + - {fileID: 1279948507} + - {fileID: 871483564} + - {fileID: 472708486} + - {fileID: 561813760} diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity.meta b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity.meta new file mode 100644 index 0000000..c0ff357 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPool.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5f9a4efcfd104ae42a4bd7e35bc1d016 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs new file mode 100644 index 0000000..8641440 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs @@ -0,0 +1,56 @@ +using System; +using UnityEngine; + +namespace Tools.EasyPoolKit.Demo +{ + public class RecyclableGOPoolManager : MonoBehaviour + { + [SerializeField] private GameObject buttonPrefab; + + [SerializeField] private Transform parent; + + private void Awake() + { + var buttonConfig = new RecyclablePoolConfig() + { + ObjectType = RecycleObjectType.RecyclableGameObject, + ReferenceType = typeof(ImageButton), + PoolId = "ImageButtonPool", + InitCreateCount = 5, + ReachMaxLimitType = PoolReachMaxLimitType.RecycleOldest, + MaxSpawnCount = 10, + DespawnDestroyType = PoolDespawnDestroyType.DestroyToLimit, + MaxDespawnCount = 5, + ClearType = PoolClearType.ClearToLimit, + IsIgnoreTimeScale = false, + }; + RecyclableGOPoolKit.Instance.RegisterPrefab(buttonPrefab, buttonConfig); + } + + private void Update() + { + if (Input.GetKeyDown(KeyCode.A)) + { + var newImage = RecyclableGOPoolKit.Instance.SimpleSpawn(buttonPrefab); + newImage.transform.SetParent(parent); + } + // else if (Input.GetKeyDown(KeyCode.S)) + // { + // RecyclableGOPoolKit.Instance.Despawn("Image"); + // } + // else if (Input.GetKeyDown(KeyCode.C)) + // { + // RecyclableGOPoolKit.Instance.ClearAllPools(true); + // } + // else if (Input.GetKeyDown(KeyCode.Alpha1)) + // { + // var newImage = RecyclableGOPoolKit.Instance.Spawn("Cube"); + // newImage.transform.SetParent(null); + // } + // else if (Input.GetKeyDown(KeyCode.Alpha2)) + // { + // RecyclableGOPoolKit.Instance.Despawn("Cube"); + // } + } + } +} \ No newline at end of file diff --git a/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs.meta b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs.meta new file mode 100644 index 0000000..99f7be1 --- /dev/null +++ b/Assets/Unity-Tools/Demo/EasyPoolKit/RecyclableGOPool/RecyclableGOPoolManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e8aaad6940cad364082cdb3406487a8d \ No newline at end of file