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.

45 lines
1.3 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using uc;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.SceneManagement;
#endif
using UnityEngine.SceneManagement;
public class PoolBase<Instance> : MonoBehaviour where Instance : PoolBase<Instance>
{
static Instance pool_base;
public static Instance Singleton {
get
{
if (pool_base == null)
{
Instance tmp_pool_base = FindObjectOfType<Instance>();
string typename = typeof(Instance).Name;
if (tmp_pool_base == null)
{
Debug.LogWarning(typename + " component required - adding dynamically now");
GameObject go = new GameObject(typename);
tmp_pool_base = go.AddComponent<Instance>();
}
if(Application.isPlaying)
DontDestroyOnLoad(tmp_pool_base.gameObject);
pool_base = tmp_pool_base;
}
return pool_base;
}
}
protected FileInfo GetFileInfo(string filename)
{
//return new FileInfo(PoolRoot.FullName + @"\" + filename);
return new FileInfo(filename);
}
}