示例#1
0
        IEnumerator Update(string url)
        {
            Downloader loader = new Downloader(url, _localPath, DateTime.UtcNow.ToFileTimeUtc().ToString());

            while (false == loader.isDone)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (null != loader.error)
            {
                Log.E(loader.error);
                if (null != _onError)
                {
                    _onError.Invoke(loader.error);
                }
                yield break;
            }
            loader.Dispose();

            SettingVO vo = LoadLocalSetting();

            Runtime.Ins.setting   = vo;
            Runtime.Ins.netResDir = FileSystem.CombineDirs(true, vo.netResRoot, Runtime.Ins.platform);

            if (Runtime.Ins.setting.settingJump.ContainsKey(Application.version))
            {
                ILBridge.Ins.StartCoroutine(Update(Runtime.Ins.setting.settingJump[Application.version]));
            }
            else
            {
                _onLoaded();
            }
            yield break;
        }
示例#2
0
        private void Start()
        {
            var cfg = Runtime.Ins.VO;

            if (null == cfg)
            {
                return;
            }
            bool isUseDll = cfg.isUseDll && cfg.isHotResProject;

            Type type = Type.GetType(cfg.className);

            if (isUseDll || type == null)
            {
                Log.CI(Log.COLOR_ORANGE, "IL代码运行环境: [外部程序集]");

                string libDir = FileSystem.CombineDirs(false, Runtime.Ins.localResDir, HotResConst.DLL_DIR_NAME);
                //初始化IL
                ILBridge.Ins.Startup(libDir, cfg.fileName, cfg.isDebugIL, cfg.isLoadPdb);
                //调用启动方法
                ILBridge.Ins.Invoke(cfg.className, cfg.methodName);
            }
            else
            {
                Log.CI(Log.COLOR_ORANGE, "IL代码运行环境: [本地程序集]");

                //使用本地类,直接启动本地类
                MethodInfo method = type.GetMethod(cfg.methodName, BindingFlags.Static | BindingFlags.Public);
                method.Invoke(null, null);
            }
        }
示例#3
0
        public void Init(RuntimeVO vo)
        {
            _vo = vo;
            //日志控制
            Log.IsActive = vo.isLogEnable;

            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                //Android真机环境
                platform            = "android";
                streamingAssetsPath = Application.streamingAssetsPath + "/";
                netResDir           = FileSystem.CombineDirs(true, _vo.netRoot, platform);
                localResDir         = FileSystem.CombineDirs(true, Application.persistentDataPath);
                break;

            case RuntimePlatform.IPhonePlayer:
                //IOS真机环境
                platform            = "ios";
                streamingAssetsPath = string.Format("file://{0}/Raw/", Application.dataPath);
                netResDir           = FileSystem.CombineDirs(true, _vo.netRoot, platform);
                localResDir         = FileSystem.CombineDirs(true, Application.persistentDataPath);
                break;

            case RuntimePlatform.WindowsEditor:
            case RuntimePlatform.LinuxEditor:
            case RuntimePlatform.OSXEditor:
                //Editor开发环境
#if UNITY_ANDROID
                platform = "android";
#elif UNITY_IPHONE
                platform = "ios";
#else
                platform = "pc";
#endif
                streamingAssetsPath = string.Format("file://{0}/StreamingAssets/", Application.dataPath);
                if (IsLoadAssetsFromNet)
                {
                    netResDir   = FileSystem.CombineDirs(true, _vo.netRoot, platform);
                    localResDir = FileSystem.CombineDirs(true, Directory.GetParent(Application.dataPath).FullName, "Caches");
                }
                else
                {
                    netResDir   = FileSystem.CombineDirs(true, _vo.localResRoot, platform);
                    localResDir = netResDir;
                }
                break;

            default:
                //其它真机环境
                platform            = "pc";
                streamingAssetsPath = string.Format("file://{0}/StreamingAssets/", Application.dataPath);
                netResDir           = FileSystem.CombineDirs(true, _vo.netRoot, platform);
                localResDir         = FileSystem.CombineDirs(true, Application.dataPath, "StreamingAssets");
                break;
            }

            //确保本地资源目录存在
            if (false == Directory.Exists(localResDir))
            {
                Directory.CreateDirectory(localResDir);
            }

            localData   = new LocalDataModel();
            localResVer = new LocalResVerModel(localData);
        }