Exemplo n.º 1
0
        /// <summary>
        /// 启动
        /// </summary>
        public static void setup(GameObject root, Action exitRun = null)
        {
            if (_inited)
            {
                return;
            }

            _inited = true;

            _root = root;

            GameObject.DontDestroyOnLoad(_root);

            _exitRun = exitRun;

            _rootBehavious = _root.AddComponent <ShineBehavious>();

            SystemControl.init();
            ThreadControl.init();
            DateControl.init();
            NetControl.init();
            BytesControl.init();

            //显示部分
            if (ShineSetting.isWholeClient)
            {
                SKeyboardControl.init();
                STouchControl.init();
                UIControl.init();

                CameraControl.init();
                Tween.init();

                LoadControl.init();
                ResourceInfoControl.init();
                AssetPoolControl.init();
            }
            else
            {
                //gm指令所需
                if (ShineSetting.needGMCommandUI)
                {
                    SKeyboardControl.init();
                    STouchControl.init();
                    UIControl.init();
                }

                ShineSetting.debugJumpResourceVersion = true;
                ResourceInfoControl.initBase();
            }
        }
Exemplo n.º 2
0
        /** 加载一个 */
        public void loadOne(int id)
        {
            //-1不加载
            if (id == -1)
            {
                clear();

                _isLoading = false;
                //不返回
                return;
            }

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

            toClear(false);

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

            _isLoading = true;

            AssetPoolControl.loadOne(_type, _resourceID = id, () =>
            {
                if (_index == index && LoadControl.getVersion() == _loadVersion)
                {
                    _isLoading = false;

                    releaseCache();

                    _cacheResourceID = id;
                    _cacheObject     = AssetPoolControl.getAsset(_type, id);

                    if (_cacheObject == null)
                    {
                        Ctrl.throwError("获取Asset为空,可能是业务层调用了Destroy", _type, id);
                    }
                    else
                    {
                        if (_completeCall != null)
                        {
                            _completeCall(_cacheObject);
                        }
                    }
                }
            });
        }
Exemplo n.º 3
0
        private void releaseCache()
        {
            if (_cacheResourceID != -1)
            {
                if (_cacheObject != null && _releaseCall != null)
                {
                    _releaseCall(_cacheObject);
                }

                AssetPoolControl.unloadOne(_type, _cacheResourceID, _cacheObject);
                _cacheObject     = null;
                _cacheResourceID = -1;
            }
        }