252 lines
7.9 KiB
C#
252 lines
7.9 KiB
C#
|
//using System;
|
||
|
//using System.Collections;
|
||
|
//using System.Collections.Generic;
|
||
|
|
||
|
//using UnityEngine;
|
||
|
|
||
|
//namespace ET
|
||
|
//{
|
||
|
|
||
|
// public class PoolAwakeSystem : AwakeSystem<Pool>
|
||
|
// {
|
||
|
// public override void Awake(Pool self)
|
||
|
// {
|
||
|
// self.Awake();
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
|
||
|
// public class PoolStartSystem : StartSystem<Pool>
|
||
|
// {
|
||
|
// public override void Start(Pool self)
|
||
|
// {
|
||
|
// self.Start();
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// //
|
||
|
// //public class PoolUpdateSystem : UpdateSystem<Pool>
|
||
|
// //{
|
||
|
// // public override void Update(Pool self)
|
||
|
// // {
|
||
|
// // self.Update();
|
||
|
// // }
|
||
|
// //}
|
||
|
|
||
|
|
||
|
// public class PoolDestroySystem : DestroySystem<Pool>
|
||
|
// {
|
||
|
// public override void Destroy(Pool self)
|
||
|
// {
|
||
|
// self.Destroy();
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// public class Pool : Entity
|
||
|
// {
|
||
|
// //public ClassObjectPool ClassObjectPool { get; private set; }
|
||
|
// public GameObjectPool GameObjectPool { get; private set; }
|
||
|
// //public AssetBundlePool AssetBundlePool { get; private set; }
|
||
|
|
||
|
|
||
|
// public int ReleaseClassObjectInterval { get; private set; }
|
||
|
// public int ReleaseAssetBundleInterval { get; private set; }
|
||
|
// public int ReleaseAssetInterval { get; private set; }
|
||
|
|
||
|
|
||
|
// public float ReleaseClassObjectNextRunTime { get; private set; }
|
||
|
// /// <summary>
|
||
|
// /// 下次释放资源运行时间
|
||
|
// /// </summary>
|
||
|
// public float ReleaseAssetBundleNextRunTime { get; private set; }
|
||
|
// /// <summary>
|
||
|
// /// 下次释放资源运行时间
|
||
|
// /// </summary>
|
||
|
// public float ReleaseAssetNextRunTime { get; private set; }
|
||
|
// public void Awake()
|
||
|
// {
|
||
|
// //GameObjectPool = EntityFactory.CreateWithParent<GameObjectPool>(this);
|
||
|
// //ClassObjectPool = EntityFactory.CreateWithParent<ClassObjectPool>(this);
|
||
|
// //AssetBundlePool = EntityFactory.CreateWithParent<AssetBundlePool, string>(this, "AssetBundlePool");
|
||
|
// //AssetPool = new Dictionary<AssetCategory, AssetBundlePool>();
|
||
|
|
||
|
// m_InstanceResourceDic = new Dictionary<int, ResourceEntity>();
|
||
|
|
||
|
// }
|
||
|
|
||
|
// public void Start()
|
||
|
// {
|
||
|
|
||
|
// ReleaseClassObjectNextRunTime = Time.time;
|
||
|
// ReleaseAssetBundleNextRunTime = Time.time;
|
||
|
// ReleaseAssetNextRunTime = Time.time;
|
||
|
// InitClassReside();
|
||
|
|
||
|
// }
|
||
|
// /// <summary>
|
||
|
// /// 初始化常用类常驻数量
|
||
|
// /// </summary>
|
||
|
// private void InitClassReside()
|
||
|
// {
|
||
|
// //ReferencePool.SetResideCount<HttpRoutine>(3);
|
||
|
// //ClassObjectPool.SetResideCount<AssetBundleLoadRoutine>(10);
|
||
|
// //ClassObjectPool.SetResideCount<AssetLoadRoutine>(10);
|
||
|
// //ClassObjectPool.SetResideCount<Dictionary<string, object>>(3);
|
||
|
// //ClassObjectPool.SetResideCount<ResourceEntity>(10);
|
||
|
// //ClassObjectPool.SetResideCount<MainAssetLoaderRoutine>(30);
|
||
|
// }
|
||
|
// #region ClassObjectPool
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// /// <summary>
|
||
|
// /// 取出一个对象
|
||
|
// /// </summary>
|
||
|
// /// <typeparam name="T"></typeparam>
|
||
|
// /// <returns></returns>
|
||
|
// //public T DequeueClassObject<T>() where T : class, new()
|
||
|
// //{
|
||
|
// // return ClassObjectPool.DequeueClassObject<T>();
|
||
|
// //}
|
||
|
|
||
|
// ///// <summary>
|
||
|
// ///// 对象回池
|
||
|
// ///// </summary>
|
||
|
// ///// <param name="obj"></param>
|
||
|
// //public void EnqueueClassObject(object obj)
|
||
|
// //{
|
||
|
// // ClassObjectPool.EnqueueClassObject(obj);
|
||
|
// //}
|
||
|
// #endregion
|
||
|
// #region 实例管理和分类资源池释放
|
||
|
|
||
|
// private Dictionary<int, ResourceEntity> m_InstanceResourceDic;
|
||
|
// /// <summary>
|
||
|
// /// 注册到实例字典
|
||
|
// /// </summary>
|
||
|
// /// <param name="id"></param>
|
||
|
// /// <param name="resEntity"></param>
|
||
|
// internal void RegistInstanceResource(int id, ResourceEntity resEntity)
|
||
|
// {
|
||
|
// m_InstanceResourceDic[id] = resEntity;
|
||
|
// }
|
||
|
|
||
|
// public void ReleaseInstanceResource(int id)
|
||
|
// {
|
||
|
// if (m_InstanceResourceDic.TryGetValue(id, out ResourceEntity resourceEntity))
|
||
|
// {
|
||
|
// if (Define.IsEditorMode)
|
||
|
// {
|
||
|
// resourceEntity.Target = null;
|
||
|
// //todo:
|
||
|
// //Game.Scene.GetComponent<Pool>().EnqueueClassObject(resourceEntity);
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// DespawnResourceEntity(resourceEntity);
|
||
|
// }
|
||
|
// m_InstanceResourceDic.Remove(id);
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// private void DespawnResourceEntity(ResourceEntity resourceEntity)
|
||
|
// {
|
||
|
// //var curr = resourceEntity.DependsResourceList.First;
|
||
|
// //while (curr != null)
|
||
|
// //{
|
||
|
// // DespawnResourceEntity(curr.Value);
|
||
|
// // curr = curr.Next;
|
||
|
// //}
|
||
|
// //AssetPool[resourceEntity.Category]?.Despawn(resourceEntity.ResourceName);
|
||
|
// }
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// #region GameObjectPool
|
||
|
|
||
|
// /// <summary>
|
||
|
// /// 物体对象池初始化
|
||
|
// /// </summary>
|
||
|
// internal void InitGameObjectPool()
|
||
|
// {
|
||
|
// GameObjectPool.Init(UnityRoot.Instance.GameObjectPoolGroups, UnityRoot.Instance.ObjPoolParent);
|
||
|
// }
|
||
|
|
||
|
// /// <summary>
|
||
|
// /// 从对象池中获取对象
|
||
|
// /// </summary>
|
||
|
// /// <param name="poolId"></param>
|
||
|
// /// <param name="prefab"></param>
|
||
|
// /// <param name="onComplete"></param>
|
||
|
// //public void GameObjectSpawn(byte poolId, Transform prefab, Action<Transform> onComplete)
|
||
|
// //{
|
||
|
// // GameObjectPool.Spawn(poolId, prefab, onComplete);
|
||
|
// //}
|
||
|
// /// <summary>
|
||
|
// /// 从对象池中获取对象
|
||
|
// /// </summary>
|
||
|
// /// <param name="poolId"></param>
|
||
|
// /// <param name="onComplete"></param>
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// public void Update()
|
||
|
// {
|
||
|
|
||
|
// //if (Time.time > ReleaseClassObjectNextRunTime + ReleaseClassObjectInterval)
|
||
|
// //{
|
||
|
// // //该释放资源了
|
||
|
// // ReleaseClassObjectNextRunTime = Time.time;
|
||
|
// // ReleaseClassObjectPool();
|
||
|
// //}
|
||
|
// //if (Time.time > ReleaseAssetBundleNextRunTime + ReleaseAssetBundleInterval)
|
||
|
// //{
|
||
|
// // //该释放资源了
|
||
|
// // ReleaseAssetBundleNextRunTime = Time.time;
|
||
|
// // if (!Define.IsEditorMode)
|
||
|
// // {
|
||
|
// // ReleaseAssetBundlePool();
|
||
|
// // }
|
||
|
// //}
|
||
|
// //if (Time.time > ReleaseAssetNextRunTime + ReleaseAssetInterval)
|
||
|
// //{
|
||
|
// // //该释放资源了
|
||
|
// // ReleaseAssetNextRunTime = Time.time;
|
||
|
// // if (!Define.IsEditorMode)
|
||
|
// // {
|
||
|
// // ReleaseAssetPool();
|
||
|
// // }
|
||
|
// // Resources.UnloadUnusedAssets();
|
||
|
// //}
|
||
|
// }
|
||
|
|
||
|
// /// <summary>
|
||
|
// /// 释放类对象池
|
||
|
// /// </summary>
|
||
|
// public void ReleaseClassObjectPool()
|
||
|
// {
|
||
|
// //ClassObjectPool.Release();
|
||
|
// }
|
||
|
// /// <summary>
|
||
|
// /// 释放AssetBundle池
|
||
|
// /// </summary>
|
||
|
// public void ReleaseAssetBundlePool()
|
||
|
// {
|
||
|
// //AssetBundlePool.Release();
|
||
|
// }
|
||
|
// /// <summary>
|
||
|
// /// 释放分类资源池的所有资源
|
||
|
// /// </summary>
|
||
|
// internal void ReleaseAssetPool()
|
||
|
// {
|
||
|
|
||
|
// }
|
||
|
// public void Destroy()
|
||
|
// {
|
||
|
// //ClassObjectPool.Dispose();
|
||
|
// //GameObjectPool.Dispose();
|
||
|
// //AssetBundlePool.Dispose();
|
||
|
// }
|
||
|
// }
|
||
|
//}
|