Пример #1
0
        /** 加载一个 */
        public void loadOne(int id)
        {
            //-1不加载
            if (id == -1)
            {
                clear();
                //直接返回
                onComplete();
                return;
            }

            //相同资源,加载中跳过
            if (_isLoading && _resourceID == id)
            {
                return;
            }

            clear();

            _loadVersion = LoadControl.getVersion();
            int index = ++_index;

            _isLoading = true;

            LoadControl.loadOne(_resourceID = id, () =>
            {
                if (_index == index && LoadControl.getVersion() == _loadVersion)
                {
                    onComplete();
                }
            }, _priority);
        }
Пример #2
0
    public void loadSplit(int type, string configName, int key, Action <BaseConfig> overFunc)
    {
        int configResourceID = LoadControl.getResourceIDByNameAbs(getSplitConfigPath(configName, key));

        LoadControl.loadOne(configResourceID, () =>
        {
            byte[] bytes = (byte[])LoadControl.getResource(configResourceID);

            BytesReadStream stream = _tempStream;

            stream.setBuf(bytes);

            if (CommonSetting.configNeedCompress)
            {
                stream.unCompress();
            }

            if (!stream.checkVersion(ShineGlobal.configVersion))
            {
                Ctrl.errorLog("config结构版本不对");
                return;
            }

            if (!checkSplitStream(stream))
            {
                return;
            }

            BaseConfig bConfig = _useData.readBytesOneSplit(type, stream);

            overFunc(bConfig);
        });
    }
Пример #3
0
            public void loadOne(Action overFunc)
            {
                ++_refCount;

                //自定义
                if (id < -1)
                {
                    overFunc();
                }
                else
                {
                    if (_loadState == LoadState_Complete)
                    {
                        overFunc();
                    }
                    else
                    {
                        _callFuncs.add(overFunc);

                        if (_loadState == LoadState_Free)
                        {
                            _loadState = LoadState_Loading;

                            LoadControl.loadOne(id, onLoadComplete);
                        }
                    }
                }
            }
Пример #4
0
    /** 加载 */
    protected void load(int resource)
    {
        //未加载好
        if (_smodel == null)
        {
            if (_loadState == 0)
            {
                _loadState    = 1;
                _loadVersion  = LoadControl.getVersion();
                _loadResource = resource;

                LoadControl.loadOne(resource, onLoadComplete, LoadPriorityType.UI);
            }
        }
        //已加载好
        else
        {
            onMakeComplete();
        }
    }
Пример #5
0
    /// <summary>
    /// 播放音效
    /// </summary>
    public void playSound(int id)
    {
        if (id <= 0)
        {
            return;
        }

        if (!_soundSwitch)
        {
            return;
        }

        LoadControl.loadOne(id, () =>
        {
            AudioClip audioClip     = LoadControl.getUnityObjectByType <AudioClip>(id);
            AudioSource audioSource = _soundGameObjectPool.getOne();

            audioSource.gameObject.SetActive(true);
            audioSource.clip = audioClip;
            audioSource.Play();
            _soundList.add(audioSource);
        });
    }
Пример #6
0
        /// <summary>
        /// 刷新语言
        /// </summary>
        public void refreshLanguage()
        {
#if UNITY_EDITOR
            GameC.app.initConfigForEditor();
#endif
            //补丁,以后想办法
            if (FontConfig.getDic() == null)
            {
                Ctrl.print("**********************出现异常情况***************");
                return;
            }

            //暂时加个补丁
            if (_fontId == -1)
            {
                _fontId = 1;
            }

            //获取字体
            string fontSource = FontConfig.getFontSource(_fontId);

            if (String.IsNullOrEmpty(fontSource))
            {
                return;
            }

            if (font != null)
            {
                if (fontSource.Contains(this.font.name))
                {
                    return;
                }
            }

            Font loadFont = null;

            if (ShineSetting.isEditor)
            {
#if UNITY_EDITOR
                if (fontSource.Contains("Arial"))
                {
                    this.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
                }
                else
                {
                    this.font = AssetDatabase.LoadAssetAtPath <Font>("Assets/source/" + fontSource);
                }
#endif
            }
            else
            {
                if (fontSource.Contains("Arial"))
                {
                    loadFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;

                    if (loadFont != null)
                    {
                        this.font = loadFont;
                    }
                }
                else
                {
                    LoadControl.loadOne(fontSource, () =>
                    {
                        if (this != null)
                        {
                            loadFont = LoadControl.getResource(fontSource) as Font;

                            if (loadFont != null)
                            {
                                this.font = loadFont;
                            }
                        }
                    });
                }
            }
        }