Beispiel #1
0
        //public static byte[] LoadLuaFile(string path)
        //{
        //    byte[] content = null;

        //    if (!AppEnv.IsUseAB)
        //    {
        //        if (!path.EndsWith(".lua"))
        //            path += ".lua";

        //        string fullPath = $"{Application.dataPath}/{path}";
        //        FileHelper.LoadFileByFileStream(fullPath, out content);
        //    }
        //    else
        //    {
        //        path = path.Replace(".lua", "");
        //        content = BundleManager.LoadLuaFile(path);
        //    }

        //    return content;
        //}

        public static void AddCacheObject(string path, int count)
        {
            ResourcePool resourcePool;

            if (ResourcePoolManager._resourcePoolDict.TryGetValue(path, out resourcePool))
            {
                return;
            }

            Object asset = LoadAsset(path, typeof(GameObject), false);
            var    obj   = InstantiateObject(asset) as GameObject;

            resourcePool = new ResourcePool(obj, ResourcePoolManager._poolParent);
            ResourcePoolManager._resourcePoolDict.Add(path, resourcePool);

            for (int i = 0; i < count; i++)
            {
                resourcePool.Despawn(InstantiateObject(asset) as GameObject);
            }
        }
Beispiel #2
0
 public void Despawn()
 {
     pool.Despawn(gameObject);
 }