Exemplo n.º 1
0
            public void UnpackRequest(AssetLoadRequest <T> req, UnityObject unityObj)
            {
                if (_isDisposed)
                {
                    _logger.Error("Call UnpackRequest On Disposed Asset Load Request Batch!");
                    return;
                }
                _loadedUnityObjects[req.BatchIndex] = unityObj;
                unityObj.SetActive(false);
                req.ReferenceBatch = null;
                _referenceCount--;
                if (_referenceCount <= 0)
                {
                    _referenceCount = 0;

                    if (_onLoaded != null)
                    {
                        try
                        {
                            if (_autoActive)
                            {
                                for (var i = 0; i < _loadedUnityObjects.Count; i++)
                                {
                                    var unity = _loadedUnityObjects[i];
                                    if (unity != null)
                                    {
                                        unity.SetActive(true);
                                    }
                                }
                            }

                            _onLoaded(_source, _loadedUnityObjects);
                        }
                        catch (Exception e)
                        {
                            _logger.Error("Batch OnLoaded Callback Error", e);
                        }
                    }

                    Free(this);
                }
            }
Exemplo n.º 2
0
        private bool TryLoadAsGameObject(Object obj, AssetInfo assetInfo, AbstractAssetLoadRequest req)
        {
            var go = obj as GameObject;

            if (go != null)
            {
                var profiler = SingletonManager.Get <LoadRequestProfileHelp>().GetProfile(assetInfo);
                profiler.InstantiateTimes++;

                obj = Object.Instantiate(go, GetGameObjectParent(req), false);
                go  = obj as GameObject;
            }

            var unityObj = new UnityObject(obj, assetInfo);

            req.LoadedObject = unityObj;
            if (req.AutoActive)
            {
                unityObj.SetActive(true);
            }

            if (go != null)
            {
                unityObj.WithPostProcessor(req.Option.PostProcessorFactory).OnLoadFromAsset();
                if (req.Option.Recyclable)
                {
                    unityObj.AddUnityObjectReference();
                }

                var profiler = SingletonManager.Get <LoadRequestProfileHelp>().GetProfile(assetInfo);
                profiler.TotalInstantiateTime += profiler.StopWatch();

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
 public virtual void Dispose()
 {
     IsDisposed   = false;
     LoadedObject = null;
     Option       = AssetLoadOption.Default;
 }
Exemplo n.º 4
0
 public void Add(UnityObject unityObj)
 {
     unityObj.OnDestory();
     unityObj.Destroy();
 }
Exemplo n.º 5
0
 public void Add(UnityObject unityObj, bool active = false)
 {
     unityObj.OnDestory();
     unityObj.Destroy();
 }