mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-08 10:33:52 +08:00
Cleanup Pool.cs
This commit is contained in:
parent
b0bbeb3cf8
commit
bfa73bcb55
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,9 +4,16 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
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
|
public abstract class Pool
|
||||||
{
|
{
|
||||||
protected static readonly Dictionary<Type, Pool> pools = new Dictionary<Type, 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);
|
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 class Pool<T> : Pool where T : IPooledObject
|
||||||
{
|
{
|
||||||
public static Pool<T> GetPool() => (Pool<T>)GetPool(typeof(T));
|
public static Pool<T> GetPool() => (Pool<T>)GetPool(typeof(T));
|
@ -290,8 +290,7 @@
|
|||||||
<Compile Include="UI\Inspectors\ReflectionInspector.cs" />
|
<Compile Include="UI\Inspectors\ReflectionInspector.cs" />
|
||||||
<Compile Include="UI\CacheObject\IValues\InteractiveValueStruct.cs" />
|
<Compile Include="UI\CacheObject\IValues\InteractiveValueStruct.cs" />
|
||||||
<Compile Include="UI\Models\InputFieldRef.cs" />
|
<Compile Include="UI\Models\InputFieldRef.cs" />
|
||||||
<Compile Include="UI\Models\ObjectPool\IPooledObject.cs" />
|
<Compile Include="UI\Pool.cs" />
|
||||||
<Compile Include="UI\Models\ObjectPool\Pool.cs" />
|
|
||||||
<Compile Include="UI\Panels\LogPanel.cs" />
|
<Compile Include="UI\Panels\LogPanel.cs" />
|
||||||
<Compile Include="UI\Panels\CSConsolePanel.cs" />
|
<Compile Include="UI\Panels\CSConsolePanel.cs" />
|
||||||
<Compile Include="Core\Utility\IOUtility.cs" />
|
<Compile Include="Core\Utility\IOUtility.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user