public LoadingEventArgs(ELoadingState State, Exception Exception = null)
        {
            this.State     = State;
            this.Exception = Exception;

            Core.Diagnostics.Log(this);
        }
Esempio n. 2
0
        public override void Update()
        {
            if (_loadingState == ELoadingState.Loading)
            {
                if (_www == null)
                {
                    _loadingState = ELoadingState.LoadedFailed;
                }
                else if (_www.isDone)
                {
                    if (_www.error != null || _www.assetBundle == null)
                    {
                        _loadingState = ELoadingState.LoadedFailed;
                    }
                    else
                    {
                        _assetBundle = _www.assetBundle;
                        if (_assetBundle == null)
                        {
                            _loadingState = ELoadingState.LoadedFailed;
                        }
                        else
                        {
                            _loadingState = ELoadingState.WaitToCallback;
                        }
                    }
                }
            }
            else if (_loadingState == ELoadingState.WaitToCallback)
            {
                _loadingState = ELoadingState.Loaded;
#if UNITY_EDITOR
                //if (IsNeedToChangeShader)
                {
                    GameObject go = _assetBundle.mainAsset as GameObject;
                    if (go != null)
                    {
                        BundleManager.ChangeShader(go.transform);
                    }
                }
#endif
                OnLoadingComplete();
                if (_www != null)
                {
                    _www.Dispose();
                    _www = null;
                }
            }
            else if (_loadingState == ELoadingState.LoadedFailed)
            {
                OnLoadingFailed();
                if (_www != null)
                {
                    _www.Dispose();
                    _www = null;
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 初始化
 /// </summary>
 public void Init(string url, string assetName, bool holdBundle)
 {
     _url          = url;
     _assetName    = assetName;
     _holdBundle   = holdBundle;
     _refCount     = 0;
     _loadingState = ELoadingState.None;
     _memoryState  = EMemoreyState.Temp;
 }
Esempio n. 4
0
 public AssetBundleLoader(string path, EResourceType type)
 {
     _path         = path;
     _loadingState = ELoadingState.Waiting;
     _type         = type;
     if (type == EResourceType.Effect || EResourceType.CharacterModel == type)
     {
         _isAlwaysInMemory = false;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 销毁
        /// </summary>
        public void Destroy()
        {
            _url          = null;
            _refCount     = 0;
            _loadingState = ELoadingState.None;
            _unusedTick   = 0;

            if (_assetBundle != null)
            {
                _assetBundle.Unload(false);
            }
            _assetBundle = null;
            _memoryState = EMemoreyState.Temp;
            Cleanup();
        }
Esempio n. 6
0
        private void OnLoadScene(Object p_sender, EventArgs p_args)
        {
            StartSceneLoadEventArgs startSceneLoadEventArgs = (StartSceneLoadEventArgs)p_args;

            if (String.IsNullOrEmpty(startSceneLoadEventArgs.SceneName))
            {
                throw new ArgumentNullException("p_sceneName");
            }
            Debug.Log("Start load scene: '" + startSceneLoadEventArgs.SceneName + "'");
            m_DebugLoadTime   = Time.realtimeSinceStartup;
            m_LastTargetScene = m_TargetScene;
            m_TargetScene     = startSceneLoadEventArgs.SceneName;
            LoadProgress      = 0f;
            IsDone            = false;
            enabled           = true;
            m_LoadState       = ELoadingState.Initiated;
        }
Esempio n. 7
0
        public override void Start()
        {
            string url = _path;

            try
            {
                _startTime = Time.realtimeSinceStartup;
                //_www = WWW.LoadFromCacheOrDownload(url,0);
                _www = new WWW(url);
            }
            catch (Exception e)
            {
                LogModule.ErrorLog(url + e);
                throw;
            }
            _loadingState = ELoadingState.Loading;
        }
Esempio n. 8
0
 public override void Unload(bool unloadAllLoadedObjects)
 {
     if (_loadingState == ELoadingState.UnLoaded)
     {
         LogModule.ErrorLog("Unload Failed,has unloaded!");
         return;
     }
     if (_assetBundle != null)
     {
         _assetBundle.Unload(unloadAllLoadedObjects);
     }
     if (_www != null)
     {
         _www.Dispose();
     }
     _www          = null;
     _assetBundle  = null;
     _loadingState = ELoadingState.UnLoaded;
 }
Esempio n. 9
0
 public void SetStatus(ELoadingState Type, string Text)
 {
     StatusMainStatus.Text = Text;
     if (Type == ELoadingState.Information)
     {
         StatusMainStatusImage.Image = Properties.Resources.info;
     }
     else if (Type == ELoadingState.Success)
     {
         StatusMainStatusImage.Image = Properties.Resources.success;
     }
     else if (Type == ELoadingState.Warning)
     {
         StatusMainStatusImage.Image = Properties.Resources.warn;
     }
     else if (Type == ELoadingState.Error)
     {
         StatusMainStatusImage.Image = Properties.Resources.error;
     }
     Application.DoEvents();             // refresh Client
 }
Esempio n. 10
0
        private void Update()
        {
            if (m_CurrentOperation != null)
            {
                if (!m_CurrentOperation.isDone)
                {
                    AsyncOperationProcess();
                    return;
                }
                AsyncOperationDone();
                m_CurrentOperation = null;
                NextLoadState();
            }
            switch (m_LoadState)
            {
            case ELoadingState.Initiated:
                NextLoadState();
                break;

            case ELoadingState.LoadEmptyScene:
                Application.LoadLevel("Empty");
                NextLoadState();
                break;

            case ELoadingState.Skip:
                if (!String.IsNullOrEmpty(m_LastTargetScene))
                {
                    AssetBundleManagers.Instance.Main.UnloadAssetBundleByAssetName(m_LastTargetScene, true, false, true);
                    AssetBundleManagers.Instance.Mod.UnloadAssetBundleByAssetName(m_LastTargetScene, true, false, true);
                }
                AssetBundleManagers.Instance.Main.UnloadManager(false);
                AssetBundleManagers.Instance.Mod.UnloadManager(false);
                NextLoadState();
                break;

            case ELoadingState.GarbageCollecting:
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                NextLoadState();
                break;

            case ELoadingState.UnloadUnusedAssets:
                m_CurrentOperation = Resources.UnloadUnusedAssets();
                break;

            case ELoadingState.LoadTargetSceneAssetBundle:
            {
                SceneRequest sceneRequest = null;
                if (LegacyLogic.Instance.ModController.InModMode)
                {
                    sceneRequest = AssetBundleManagers.Instance.Mod.RequestScene(m_TargetScene, 0, new SceneRequestCallback(OnSceneBundleLoaded), null);
                }
                if (sceneRequest == null)
                {
                    sceneRequest = AssetBundleManagers.Instance.Main.RequestScene(m_TargetScene, 0, new SceneRequestCallback(OnSceneBundleLoaded), null);
                }
                if (sceneRequest == null)
                {
                    Debug.LogError("Scene not in a assetbundle defined! \n" + m_TargetScene);
                    m_LoadState = ELoadingState.UnloadBundles;
                }
                else
                {
                    NextLoadState();
                }
                break;
            }

            case ELoadingState.LoadTargetScene:
                m_CurrentOperation = Application.LoadLevelAsync(m_TargetScene);
                if (m_CurrentOperation == null)
                {
                    Debug.LogError("Error load scene! \n" + m_TargetScene);
                    NextLoadState();
                }
                break;

            case ELoadingState.Skip2:
                NextLoadState();
                break;

            case ELoadingState.UnloadUnusedAssets2:
                NextLoadState();
                break;

            case ELoadingState.UnloadBundles:
            {
                Camera[] array = (Camera[])FindObjectsOfType(typeof(Camera));
                for (Int32 i = 0; i < array.Length; i++)
                {
                    if (!array[i].CompareTag("UICamera"))
                    {
                        array[i].enabled = false;
                    }
                }
                GameObject gameObject = new GameObject();
                Camera     camera     = gameObject.AddComponent <Camera>();
                camera.fieldOfView         = 180f;
                camera.nearClipPlane       = 0f;
                camera.farClipPlane        = 10000f;
                camera.useOcclusionCulling = false;
                RenderTexture temporary = RenderTexture.GetTemporary(1, 1, 0);
                temporary.isCubemap = true;
                camera.RenderToCubemap(temporary);
                temporary.Release();
                RenderTexture.ReleaseTemporary(temporary);
                Destroy(gameObject);
                m_CurrentOperation = Resources.UnloadUnusedAssets();
                break;
            }

            case ELoadingState.SceneLoaded:
                NextLoadState();
                SceneLoadFinish();
                break;
            }
            LegacyLogic.Instance.MapLoader.SceneLoaderProgress = (1f - (ELoadingState.Finish - m_LoadState) / 12f) * 0.5f;
        }
Esempio n. 11
0
 /// <summary>
 /// 设置加载状态
 /// </summary>
 public void SetLoadingState(ELoadingState s)
 {
     _loadingState = s;
 }
        protected void InvokeDataLoaded(ELoadingState LoadingState, Exception Exception = null)
        {
            LoadingEventArgs <IEnumerable <T> > LEA = new LoadingEventArgs <IEnumerable <T> >(LoadingState, this, Exception);

            OnDataLoaded?.Invoke(this, LEA);
        }
Esempio n. 13
0
		public void SetStatus(ELoadingState Type, string Text) {
			StatusMainStatus.Text = Text;
			if (Type == ELoadingState.Information)
				StatusMainStatusImage.Image = Properties.Resources.info;
			else if (Type == ELoadingState.Success)
				StatusMainStatusImage.Image = Properties.Resources.success;
			else if (Type == ELoadingState.Warning)
				StatusMainStatusImage.Image = Properties.Resources.warn;
			else if (Type == ELoadingState.Error)
				StatusMainStatusImage.Image = Properties.Resources.error;
			Application.DoEvents(); // refresh Client
		}
Esempio n. 14
0
 private void _InvokeDataLoaded(ELoadingState LoadingState, Exception Exception = null)
 {
     OnDataLoaded?.Invoke(this, new LoadingEventArgs <IEnumerable <ISQLServer> >(LoadingState, this, Exception));
 }
Esempio n. 15
0
 public LoadingEventArgs(ELoadingState State, T Payload = default(T), Exception Exception = null) : base(State, Exception)
 {
     this.Payload = Payload;
 }