Example #1
0
        /// <summary>
        /// 加载配置
        /// </summary>
        /// <param name="configName">配置名称。</param>
        /// <param name="configAssetName">配置资源名称。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void LoadConfig(string configName, string configAssetName, object userData = null)
        {
            if (m_ResourceManager == null)
            {
                Debug.LogError("资源管理器为空,无法加载配置");
                return;
            }

            if (m_ConfigHelper == null)
            {
                Debug.LogError("配置辅助器为空,无法加载配置");
                return;
            }
            if (string.IsNullOrEmpty(configName))
            {
                Debug.LogError("要加载的配置名称为空,无法加载配置");
                return;
            }
            if (string.IsNullOrEmpty(configAssetName))
            {
                Debug.LogError("要加载的配置资源名称为空,无法加载配置");
                return;
            }
            LoadConfigInfo info = new LoadConfigInfo(configName, userData);

            m_ResourceManager.LoadAsset(configAssetName, m_LoadAssetCallbacks, info);
        }
        /// <summary>
        /// 填充加载配置更新事件
        /// </summary>
        /// <param name="e">内部事件。</param>
        /// <returns>加载配置更新事件。</returns>
        public LoadConfigUpdateEventArgs Fill(object userData, string configAssetName, float progress)
        {
            LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData;

            ConfigName      = loadConfigInfo.ConfigName;
            ConfigAssetName = configAssetName;
            Progress        = progress;
            UserData        = loadConfigInfo.UserData;

            return(this);
        }
Example #3
0
        /// <summary>
        /// 填充加载配置成功事件
        /// </summary>
        /// <returns>加载配置成功事件。</returns>
        public LoadConfigSuccessEventArgs Fill(object userData, string configAssetName, float duration)
        {
            LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData;

            ConfigName      = loadConfigInfo.ConfigName;
            ConfigAssetName = configAssetName;
            Duration        = duration;
            UserData        = loadConfigInfo.UserData;

            return(this);
        }
        /// <summary>
        /// 填充加载配置失败事件
        /// </summary>
        /// <param name="e">内部事件。</param>
        /// <returns>加载配置失败事件。</returns>
        public LoadConfigFailureEventArgs Fill(object userData, string configAssetName, string errorMessage)
        {
            LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData;

            ConfigName      = loadConfigInfo.ConfigName;
            ConfigAssetName = configAssetName;
            ErrorMessage    = errorMessage;
            UserData        = loadConfigInfo.UserData;

            return(this);
        }
        /// <summary>
        /// 填充加载配置时加载依赖资源事件
        /// </summary>
        /// <returns>加载配置时加载依赖资源事件</returns>
        public LoadConfigDependencyAssetEventArgs Fill(object userData, string configAssetName, string dependencyAssetName, int loadedCount, int totalCount)
        {
            LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData;

            ConfigName          = loadConfigInfo.ConfigName;
            ConfigAssetName     = configAssetName;
            DependencyAssetName = dependencyAssetName;
            LoadedCount         = loadedCount;
            TotalCount          = totalCount;
            UserData            = loadConfigInfo.UserData;

            return(this);
        }
        /// <summary>
        /// 加载配置
        /// </summary>
        /// <param name="configAsset">配置资源</param>
        /// <param name="userData">用户自定义数据</param>
        /// <returns>加载是否成功</returns>
        public bool LoadConfig(object configAsset, object userData)
        {
            LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData;

            return(LoadConfig(loadConfigInfo.ConfigName, configAsset, loadConfigInfo.UserData));
        }