コード例 #1
0
        public void RemoveInstance(IRenderObject obj)
        {
            if (!this.insts.Remove(obj))
            {
                return;
            }

            IResourceFactory.Cookie cookie = factory.GetCookie(name);
            --cookie.count;
            if (cookie.count <= 0)
            {
                cookie.create_time = Time.realtimeSinceStartup;
            }

            /* 由factory去决定什么时候Destroy之~ */
            if (this.insts.Count == 0)
            {
                idle_time = Time.realtimeSinceStartup;
                if (factory != null)
                {
                    factory.DestroyResource(this);
                }
                else
                {
                    Destroy();
                }
            }
        }
コード例 #2
0
        // 加载资源

        protected virtual void OnCreate(AssetBundle asset_bundle)
        {
            if (asset_bundle != null)
            {
                Object[] objs = asset_bundle.LoadAllAssets();
                if (objs != null && objs.Length > 0)
                {
                    this.asset = objs[0];
                }
                renders = CClientCommon.ReplaceShader(this.asset, string.Empty);
                IResourceFactory.Cookie cookie = factory.GetCookie(name);
                cookie.RecordMemory(UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(asset), asset is GameObject);
            }
        }
コード例 #3
0
        public T CreateInstance <T>(IRenderObject parent, params object[] args)
            where T : IRenderObject
        {
            T inst = AllocInstance <T>(args);

            inst.SetOwner(this);
            inst.SetParent(parent);
            if (this.complete)
            {
                inst.Create();
            }

            IResourceFactory.Cookie cookie = factory.GetCookie(name);
            ++cookie.total;
            ++cookie.count;

            idle_time = 0;
            this.insts.Add(inst);
            return(inst);
        }