public static LoadConfigInfo Create(LoadType loadType, object userData) { LoadConfigInfo loadConfigInfo = ReferencePool.Acquire <LoadConfigInfo>(); loadConfigInfo.m_LoadType = loadType; loadConfigInfo.m_UserData = userData; return(loadConfigInfo); }
private void LoadConfigUpdateCallback(string configAssetName, float progress, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GameFrameworkException("Load config info is invalid."); } if (m_LoadConfigUpdateEventHandler != null) { m_LoadConfigUpdateEventHandler(this, new LoadConfigUpdateEventArgs(configAssetName, progress, loadConfigInfo.UserData)); } }
private void LoadConfigDependencyAssetCallback(string configAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GameFrameworkException("Load config info is invalid."); } if (m_LoadConfigDependencyAssetEventHandler != null) { m_LoadConfigDependencyAssetEventHandler(this, new LoadConfigDependencyAssetEventArgs(configAssetName, dependencyAssetName, loadedCount, totalCount, loadConfigInfo.UserData)); } }
private void LoadConfigUpdateCallback(string configAssetName, float progress, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GameFrameworkException("Load config info is invalid."); } if (m_LoadConfigUpdateEventHandler != null) { LoadConfigUpdateEventArgs loadConfigUpdateEventArgs = LoadConfigUpdateEventArgs.Create(configAssetName, loadConfigInfo.LoadType, progress, loadConfigInfo.UserData); m_LoadConfigUpdateEventHandler(this, loadConfigUpdateEventArgs); ReferencePool.Release(loadConfigUpdateEventArgs); } }
private void LoadAssetDependencyAssetCallback(string configAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GXException("Load config info is invalid."); } if (m_LoadConfigDependencyAssetEventHandler != null) { LoadConfigDependencyAssetEventArgs loadConfigDependencyAssetEventArgs = LoadConfigDependencyAssetEventArgs.Create(configAssetName, dependencyAssetName, loadedCount, totalCount, loadConfigInfo.UserData); m_LoadConfigDependencyAssetEventHandler(this, loadConfigDependencyAssetEventArgs); ReferencePool.Release(loadConfigDependencyAssetEventArgs); } }
private void LoadConfigFailureCallback(string configAssetName, LoadResourceStatus status, string errorMessage, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GameFrameworkException("Load config info is invalid."); } string appendErrorMessage = Utility.Text.Format("Load config failure, asset name '{0}', status '{1}', error message '{2}'.", configAssetName, status.ToString(), errorMessage); if (m_LoadConfigFailureEventHandler != null) { m_LoadConfigFailureEventHandler(this, new LoadConfigFailureEventArgs(configAssetName, appendErrorMessage, loadConfigInfo.UserData)); return; } throw new GameFrameworkException(appendErrorMessage); }
private void LoadConfigSuccessCallback(string configAssetName, object configAsset, float duration, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GameFrameworkException("Load config info is invalid."); } try { if (!m_ConfigHelper.LoadConfig(configAsset, loadConfigInfo.LoadType, loadConfigInfo.UserData)) { throw new GameFrameworkException(Utility.Text.Format("Load config failure in helper, asset name '{0}'.", configAssetName)); } if (m_LoadConfigSuccessEventHandler != null) { LoadConfigSuccessEventArgs loadConfigSuccessEventArgs = LoadConfigSuccessEventArgs.Create(configAssetName, loadConfigInfo.LoadType, duration, loadConfigInfo.UserData); m_LoadConfigSuccessEventHandler(this, loadConfigSuccessEventArgs); ReferencePool.Release(loadConfigSuccessEventArgs); } } catch (Exception exception) { if (m_LoadConfigFailureEventHandler != null) { LoadConfigFailureEventArgs loadConfigFailureEventArgs = LoadConfigFailureEventArgs.Create(configAssetName, loadConfigInfo.LoadType, exception.ToString(), loadConfigInfo.UserData); m_LoadConfigFailureEventHandler(this, loadConfigFailureEventArgs); ReferencePool.Release(loadConfigFailureEventArgs); return; } throw; } finally { ReferencePool.Release(loadConfigInfo); m_ConfigHelper.ReleaseConfigAsset(configAsset); } }
private void LoadAssetOrBinaryFailureCallback(string configAssetName, LoadResourceStatus status, string errorMessage, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GXException("Load config info is invalid."); } string appendErrorMessage = Utility.Text.Format("Load config failure, asset name '{0}', status '{1}', error message '{2}'.", configAssetName, status.ToString(), errorMessage); if (m_LoadConfigFailureEventHandler != null) { LoadConfigFailureEventArgs loadConfigFailureEventArgs = LoadConfigFailureEventArgs.Create(configAssetName, loadConfigInfo.LoadType, appendErrorMessage, loadConfigInfo.UserData); m_LoadConfigFailureEventHandler(this, loadConfigFailureEventArgs); ReferencePool.Release(loadConfigFailureEventArgs); return; } throw new GXException(appendErrorMessage); }
/// <summary> /// 加载全局配置。 /// </summary> /// <param name="configAssetName">全局配置资源名称。</param> /// <param name="loadType">全局配置加载方式。</param> /// <param name="priority">加载全局配置资源的优先级。</param> /// <param name="userData">用户自定义数据。</param> public void LoadConfig(string configAssetName, LoadType loadType, int priority, object userData) { if (m_ResourceManager == null) { throw new GXException("You must set resource manager first."); } if (m_ConfigHelper == null) { throw new GXException("You must set config helper first."); } LoadConfigInfo loadConfigInfo = LoadConfigInfo.Create(loadType, userData); if (loadType == LoadType.TextFromAsset || loadType == LoadType.BytesFromAsset || loadType == LoadType.StreamFromAsset) { m_ResourceManager.LoadAsset(configAssetName, priority, m_LoadAssetCallbacks, loadConfigInfo); } else { m_ResourceManager.LoadBinary(configAssetName, m_LoadBinaryCallbacks, loadConfigInfo); } }
/// <summary> /// 加载全局配置。 /// </summary> /// <param name="configAssetName">全局配置资源名称。</param> /// <param name="loadType">全局配置加载方式。</param> /// <param name="priority">加载全局配置资源的优先级。</param> /// <param name="userData">用户自定义数据。</param> public void LoadConfig(string configAssetName, LoadType loadType, int priority, object userData) { if (m_ResourceManager == null) { throw new GameFrameworkException("You must set resource manager first."); } if (m_ConfigHelper == null) { throw new GameFrameworkException("You must set config helper first."); } m_ResourceManager.LoadAsset(configAssetName, priority, m_LoadAssetCallbacks, LoadConfigInfo.Create(loadType, userData)); }