Cleanup Pool.cs

This commit is contained in:
Sinai 2021-05-26 19:42:56 +10:00
parent b0bbeb3cf8
commit bfa73bcb55
3 changed files with 10 additions and 24 deletions

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace UnityExplorer.UI.Models
{
public interface IPooledObject
{
GameObject UIRoot { get; set; }
GameObject CreateContent(GameObject parent);
float DefaultHeight { get; }
//GameObject CreatePrototype();
}
}

View File

@ -4,9 +4,16 @@ using System.Linq;
using System.Text;
using UnityEngine;
namespace UnityExplorer.UI.Models
namespace UnityExplorer.UI
{
// Abstract non-generic class, handles the pool dictionary and interfacing with the generic pools.
public interface IPooledObject
{
GameObject UIRoot { get; set; }
float DefaultHeight { get; }
GameObject CreateContent(GameObject parent);
}
public abstract class Pool
{
protected static readonly Dictionary<Type, Pool> pools = new Dictionary<Type, Pool>();
@ -39,7 +46,6 @@ namespace UnityExplorer.UI.Models
protected abstract void TryReturn(IPooledObject obj);
}
// Each generic implementation has its own pool, business logic is here
public class Pool<T> : Pool where T : IPooledObject
{
public static Pool<T> GetPool() => (Pool<T>)GetPool(typeof(T));

View File

@ -290,8 +290,7 @@
<Compile Include="UI\Inspectors\ReflectionInspector.cs" />
<Compile Include="UI\CacheObject\IValues\InteractiveValueStruct.cs" />
<Compile Include="UI\Models\InputFieldRef.cs" />
<Compile Include="UI\Models\ObjectPool\IPooledObject.cs" />
<Compile Include="UI\Models\ObjectPool\Pool.cs" />
<Compile Include="UI\Pool.cs" />
<Compile Include="UI\Panels\LogPanel.cs" />
<Compile Include="UI\Panels\CSConsolePanel.cs" />
<Compile Include="Core\Utility\IOUtility.cs" />