You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
3 years ago
|
using System;
|
||
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using ET;
|
||
|
|
||
|
|
||
|
namespace UnityEngine.UI
|
||
|
{
|
||
|
[System.Serializable]
|
||
|
public class LoopScrollPrefabSource
|
||
|
{
|
||
|
public string prefabName;
|
||
|
public int poolSize = 5;
|
||
|
|
||
|
private bool inited = false;
|
||
|
public virtual GameObject GetObject(int index)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if(!inited)
|
||
|
{
|
||
|
GameObjectPoolHelper.InitPool(prefabName, poolSize);
|
||
|
inited = true;
|
||
|
}
|
||
|
return GameObjectPoolHelper.GetObjectFromPool(prefabName);
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Debug.LogError(e);
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public virtual void ReturnObject(Transform go , bool isDestroy = false)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (isDestroy)
|
||
|
{
|
||
|
UnityEngine.GameObject.Destroy(go.gameObject);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
GameObjectPoolHelper.ReturnObjectToPool(go.gameObject);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Debug.LogError(e);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|