/// <summary> /// 异步卸载场景。 /// </summary> /// <param name="sceneAssetName">要卸载场景资源的名称。</param> /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param> /// <param name="userData">用户自定义数据。</param> public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData) { if (m_ResourceManager.m_ResourceHelper == null) { throw new GameFrameworkException("You must set resource helper first."); } object asset = null; if (m_SceneToAssetMap.TryGetValue(sceneAssetName, out asset)) { m_SceneToAssetMap.Remove(sceneAssetName); m_AssetPool.Unspawn(asset); if (!m_AssetPool.ReleaseObject(asset)) { throw new GameFrameworkException(Utility.Text.Format("Unload scene '{0}' failure.", sceneAssetName)); } } else { throw new GameFrameworkException(Utility.Text.Format("Can not find asset of scene '{0}'.", sceneAssetName)); } m_ResourceManager.m_ResourceHelper.UnloadScene(sceneAssetName, unloadSceneCallbacks, userData); }
/// <summary> /// 异步卸载场景。 /// </summary> /// <param name="sceneAssetName">要卸载场景资源的名称。</param> /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param> /// <param name="userData">用户自定义数据。</param> public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData) { if (string.IsNullOrEmpty(sceneAssetName)) { throw new GameFrameworkException("Scene asset name is invalid."); } if (unloadSceneCallbacks == null) { throw new GameFrameworkException("Unload scene callbacks is invalid."); } m_ResourceLoader.UnloadScene(sceneAssetName, unloadSceneCallbacks, userData); }
/// <summary> /// 异步卸载场景。 /// </summary> /// <param name="sceneAssetName">要卸载场景资源的名称。</param> /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param> public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks) { if (string.IsNullOrEmpty(sceneAssetName)) { throw new System.Exception("Scene asset name is invalid."); } if (unloadSceneCallbacks == null) { throw new System.Exception("Unload scene callbacks is invalid."); } m_ResourceLoader.UnloadScene(sceneAssetName, unloadSceneCallbacks, null); }
/// <summary> /// 异步卸载场景。 /// </summary> /// <param name="sceneAssetName">要卸载场景资源的名称。</param> /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param> /// <param name="userData">用户自定义数据。</param> public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData) { if (m_ResourceManager.m_ResourceHelper == null) { throw new System.Exception("You must set resource helper first."); } object asset = null; if (m_SceneToAssetMap.TryGetValue(sceneAssetName, out asset)) { m_SceneToAssetMap.Remove(sceneAssetName); m_AssetPool.Unspawn(asset); } else { throw new System.Exception(string.Format("Can not find asset of scene '{0}'.", sceneAssetName)); } m_ResourceManager.m_ResourceHelper.UnloadScene(sceneAssetName, unloadSceneCallbacks, userData); }