Exemple #1
0
		private void OnUILoginLoad(Asset asset, EAssetResult result)
		{
			if (result != EAssetResult.OK)
				return;

			_uiLogin.GameObj.transform.SetParent(_uiDesktop, false);

			// 获取UIManifest组件
			UIManifest manifest = _uiLogin.GameObj.GetComponent<UIManifest>();

			// 获取UISprite组件
			_loginSprite = manifest.GetComponent("UILogin/BtnLogin", "UISprite") as UISprite;

			// 通过配表数据设置文本
			var hero1 = CfgHero.Instance.GetCfgTab(1001);
			var text1 = manifest.GetComponent("UILogin/Text1", "Text") as Text;
			text1.text = hero1.Name;
			Debug.Log($"热更新表格数据:{hero1.Name}");

			// 通过配表数据设置文本
			var hero2 = CfgHero.Instance.GetCfgTab(1002);
			var text2 = manifest.GetComponent("UILogin/Text2", "Text") as Text;
			text2.text = hero2.Name;
			Debug.Log($"热更新表格数据:{hero2.Name}");

			// 监听按钮点击事件
			Button btnLogin = manifest.GetComponent("UILogin/BtnLogin", "Button") as Button;
			btnLogin.onClick.AddListener(OnClickLogin);
		}
Exemple #2
0
        // 当资源文件加载完毕
        private void OnAssetFileLoad(AssetFileLoader loader)
        {
            // 注意 : 如果在加载过程中调用UnLoad,等资源文件加载完毕时不再执行后续准备工作。
            if (Result != EAssetResult.Loading)
            {
                return;
            }

            // Check error
            if (loader.LoadState != EAssetFileLoadState.LoadAssetFileOK)
            {
                Result = EAssetResult.Failed;
                _userCallback?.Invoke(this);
                return;
            }

            if (this is AssetScene || this is AssetPackage)
            {
                bool result = OnPrepare(null);
                Result = result ? EAssetResult.OK : EAssetResult.Failed;
                _userCallback?.Invoke(this);
            }
            else if (this is AssetObject)
            {
                loader.LoadMainAsset(null, OnMainAssetLoad);
            }
            else
            {
                throw new System.NotImplementedException($"Not support invalid asset class.");
            }
        }
Exemple #3
0
 /// <summary>
 /// 卸载
 /// </summary>
 public void UnLoad()
 {
     Result        = EAssetResult.None;
     _userCallback = null;
     if (_cacheLoader != null)
     {
         _cacheLoader.Release();
         _cacheLoader = null;
     }
 }
Exemple #4
0
		private void OnUIRootLoad(Asset asset, EAssetResult result)
		{
			if (result != EAssetResult.OK)
				return;

			GameObject.DontDestroyOnLoad(_uiRoot.GameObj);

			// 获取桌面对象
			// 说明:该对象主要用于调整齐刘海
			_uiDesktop = _uiRoot.GameObj.transform.FindChildByName("UIDesktop");

			// 加载登录界面
			_uiLogin = new AssetObject();
			_uiLogin.Load("UIPanel/UILogin", OnUILoginLoad);
		}
    private void OnConfigPrepare(Asset asset, EAssetResult result)
    {
        if (result != EAssetResult.OK)
        {
            return;
        }

        // 测试打印表格数据
        if (asset is CfgHero)
        {
            CfgHeroTab tab1 = CfgHero.GetCfgTab(1001);
            Debug.Log($"非热更新表格数据:{tab1.Name}");

            CfgHeroTab tab2 = CfgHero.GetCfgTab(1002);
            Debug.Log($"非热更新表格数据:{tab2.Name}");
        }
    }
    private void OnLanguageConfigPrepare(Asset asset, EAssetResult result)
    {
        if (result != EAssetResult.OK)
        {
            return;
        }

        // 加载所有配表
        foreach (int value in System.Enum.GetValues(typeof(EConfigType)))
        {
            if (value == (int)EConfigType.AutoGenerateLanguage)
            {
                continue;
            }
            string cfgName = System.Enum.GetName(typeof(EConfigType), value);
            CfgManager.Instance.Load(cfgName, OnConfigPrepare);
        }
    }
Exemple #7
0
        // 当主资源对象加载完毕
        private void OnMainAssetLoad(UnityEngine.Object mainAsset)
        {
            // 注意 : 如果在加载过程中调用UnLoad,等资源对象加载完毕时不再执行后续准备工作。
            if (Result != EAssetResult.Loading)
            {
                return;
            }

            // Check result
            if (mainAsset == null)
            {
                Result = EAssetResult.Failed;
            }
            else
            {
                bool result = OnPrepare(mainAsset);
                Result = result ? EAssetResult.OK : EAssetResult.Failed;
            }

            _userCallback?.Invoke(this);
        }
Exemple #8
0
        /// <summary>
        /// 异步加载
        /// </summary>
        public void Load(string resName, System.Action <Asset> userCallbcak)
        {
            // 防止重复加载
            if (Result != EAssetResult.None)
            {
                LogSystem.Log(ELogType.Warning, $"Asset {ResName} is already load.");
                return;
            }

            if (_cacheLoader != null)
            {
                LogSystem.Log(ELogType.Warning, $"Asset  {ResName}  loader must null.");
                return;
            }

            ResName       = resName;
            Result        = EAssetResult.Loading;
            _userCallback = userCallbcak;
            bool isStreamScene = this is AssetScene;

            _cacheLoader = AssetSystem.LoadAssetFile(ResName, isStreamScene, OnAssetFileLoad);
        }
        // 当资源加载完毕
        private void OnAssetPrepare(object assetClass, EAssetResult result)
        {
            // 如果加载失败,创建临时对象
            if (result == EAssetResult.Failed)
            {
                _go = new GameObject(ResName);
            }
            else
            {
                _go = _asset.GameObj;
            }

            // 设置游戏对象
            _go.SetActive(false);
            _go.transform.SetParent(_root);
            _go.transform.localPosition = Vector3.zero;

            // 创建初始对象
            for (int i = 0; i < Capacity; i++)
            {
                GameObject obj = GameObject.Instantiate(_go) as GameObject;
                InternalRestore(obj);
            }

            // 最后返回结果
            if (_callbacks != null)
            {
                Delegate[] actions = _callbacks.GetInvocationList();
                for (int i = 0; i < actions.Length; i++)
                {
                    var action = (Action <GameObject>)actions[i];
                    Spawn(action);
                }
                _callbacks = null;
            }
        }