Esempio n. 1
0
        /// <summary>
        /// runtime下加载,只读
        /// </summary>
        /// <param name="str"></param>
        static public void Load(AssetLoadPath loadPath)
        {
            Connection?.Dispose();
            var path = "";

            if (Application.isEditor)
            {
                if (loadPath == AssetLoadPath.Persistent)
                {
                    path = Application.persistentDataPath;
                }
                else if (loadPath == AssetLoadPath.Editor || loadPath == AssetLoadPath.StreamingAsset)
                {
                    path = Application.streamingAssetsPath;
                }
            }
            else
            {
                //真机环境db在persistent下,因为需要io
                path = Application.persistentDataPath;
            }

            //用当前平台目录进行加载
            path = GetLocalDBPath(path, Application.platform);
            if (File.Exists(path))
            {
                Connection = new SQLiteConnection(path, SQLiteOpenFlags.ReadOnly);
                BDebug.Log("DB加载路径:" + path, "red");
            }
            else
            {
                Debug.LogError("DB不存在:" + path);
            }
        }
Esempio n. 2
0
		public AssetLoadPath[] GetMenuPreLoadPaths()
		{
			var paths = new AssetLoadPath[3];
			paths[0] = new AssetLoadPath(AssetPath.GetMonsterFaceTexPath(this.ID), typeof(Sprite));
			paths[1] = new AssetLoadPath(AssetPath.GetSkillDataPath(this.ID));
			paths[2] = new AssetLoadPath(AssetPath.GetMonsterFullTexPath(this.ID), typeof(Sprite));
			return paths;
		}
Esempio n. 3
0
		public AssetLoadPath[] GetPreLoadPaths()
		{
			IEnumerable<AssetLoadPath> paths = new AssetLoadPath[] { };
			for (int i = 0; i < menkoDataList.Length; ++i)
			{
				paths = paths.Concat(menkoDataList[i].GetPreLoadPaths());
			}
			return paths.ToArray();
		}
Esempio n. 4
0
        public AssetLoadPath[] GetMenuPreLoadPaths()
        {
            var paths = new AssetLoadPath[3];

            paths[0] = new AssetLoadPath(AssetPath.GetMonsterFaceTexPath(this.ID), typeof(Sprite));
            paths[1] = new AssetLoadPath(AssetPath.GetSkillDataPath(this.ID));
            paths[2] = new AssetLoadPath(AssetPath.GetMonsterFullTexPath(this.ID), typeof(Sprite));
            return(paths);
        }
Esempio n. 5
0
		public AssetLoadPath[] GetBattlePreLoadPaths()
		{
			var paths = new AssetLoadPath[4];
			paths[0] = new AssetLoadPath(AssetPath.GetMonsterFaceTexPath(this.ID), typeof(Sprite));
			paths[1] = new AssetLoadPath(AssetPath.GetMenkoFaceMatPath(this.ID), typeof(Material));
			paths[2] = new AssetLoadPath(AssetPath.GetMenkoBackMatPath(this.Status.Element), typeof(Material));
			paths[3] = new AssetLoadPath(AssetPath.GetMonsterFullTexPath(this.ID), typeof(Sprite));
			return paths;
		}
Esempio n. 6
0
        public AssetLoadPath[] GetBattlePreLoadPaths()
        {
            var paths = new AssetLoadPath[4];

            paths[0] = new AssetLoadPath(AssetPath.GetMonsterFaceTexPath(this.ID), typeof(Sprite));
            paths[1] = new AssetLoadPath(AssetPath.GetMenkoFaceMatPath(this.ID), typeof(Material));
            paths[2] = new AssetLoadPath(AssetPath.GetMenkoBackMatPath(this.Status.Element), typeof(Material));
            paths[3] = new AssetLoadPath(AssetPath.GetMonsterFullTexPath(this.ID), typeof(Sprite));
            return(paths);
        }
Esempio n. 7
0
        public AssetLoadPath[] GetPreLoadPaths()
        {
            IEnumerable <AssetLoadPath> paths = new AssetLoadPath[] { };

            for (int i = 0; i < menkoDataList.Length; ++i)
            {
                paths = paths.Concat(menkoDataList[i].GetPreLoadPaths());
            }
            return(paths.ToArray());
        }
Esempio n. 8
0
        /// <summary>
        /// 更新服务器配置
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        private IEnumerator UpdateServerConfig(Action callback)
        {
            var url = string.Format("{0}/{1}/{2}", FileServerUrl, BDUtils.GetPlatformPath(Application.platform), "GameConfig.json");

            Debug.Log(url);
            UnityWebRequest uwq     = UnityWebRequest.Get(url);
            GameConfig      gconfig = null;

            yield return(uwq.SendWebRequest());

            if (uwq.isDone && uwq.error == null)
            {
                var text = uwq.downloadHandler.text;
                if (!string.IsNullOrEmpty(text))
                {
                    gconfig = JsonMapper.ToObject <GameConfig>(text);
                    BDebug.Log("使用服务器配置:\n" + text);
                }
            }
            else
            {
                BDebug.LogError("Game配置无法更新,使用本地");
            }


            //TODO 未来改成反射实现,暂时用这一版
            if (gconfig != null)
            {
                this.CodeRoot = (AssetLoadPath)gconfig.CodeRoot;
                this.SQLRoot  = (AssetLoadPath)gconfig.SQLRoot;
                this.ArtRoot  = (AssetLoadPath)gconfig.ArtRoot;
                //
                this.CodeRunMode = (HotfixCodeRunMode)gconfig.CodeRunMode;
                //ip相关
                this.FileServerUrl = gconfig.FileServerUrl;
                this.IsHotfix      = gconfig.IsHotfix;
                this.GateServerIp  = gconfig.GateServerIp;
                this.Port          = gconfig.Port;
                if (!Application.isEditor)
                {
                    this.IsHotfix = this.IsNeedNet = true;
                }
            }

            if (callback != null)
            {
                callback();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 脚本加载入口
        /// </summary>
        /// <param name="loadPath"></param>
        /// <param name="runMode"></param>
        /// <param name="mainProjectTypes">UPM隔离了dll,需要手动传入</param>
        static public void Load(AssetLoadPath loadPath,
                                HotfixCodeRunMode runMode,
                                Type[] mainProjectTypes,
                                Action <bool> clrBindingAction)
        {
            CLRBindAction = clrBindingAction;

            if (loadPath == AssetLoadPath.Editor)
            {
                BDebug.Log("Editor code模式!");
                //反射调用,防止编译报错
                var assembly = Assembly.GetExecutingAssembly();
                var type     = assembly.GetType("BDLauncherBridge");
                var method   = type.GetMethod("Start", BindingFlags.Public | BindingFlags.Static);
                //添加框架部分的type,热更下不需要,打包会把框架的部分打进去
                var list = new List <Type>();
                list.AddRange(mainProjectTypes);
                list.AddRange(typeof(BDLauncher).Assembly.GetTypes());
                method.Invoke(null, new object[] { list.ToArray(), null });
            }
            else
            {
                var path = "";
                if (Application.isEditor)
                {
                    if (loadPath == AssetLoadPath.Persistent)
                    {
                        path = Path.Combine(Application.persistentDataPath,
                                            BDApplication.GetPlatformPath(Application.platform));
                    }
                    else if (loadPath == AssetLoadPath.StreamingAsset)
                    {
                        path = Path.Combine(Application.streamingAssetsPath,
                                            BDApplication.GetPlatformPath(Application.platform));
                    }
                }
                else
                {
                    //真机环境,代码在persistent下,因为需要io
                    path = Path.Combine(Application.persistentDataPath,
                                        BDApplication.GetPlatformPath(Application.platform));
                }

                //加载dll
                var dllPath = Path.Combine(path, DLLPATH);
                LoadHotfixDLL(dllPath, runMode, mainProjectTypes);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="abModel"></param>
        /// <param name="callback"></param>
        static public void Load(AssetLoadPath loadPath, string customRoot = null)
        {
            if (loadPath == AssetLoadPath.Editor)
            {
#if UNITY_EDITOR  //防止编译报错
                ResLoader = new DevResourceMgr();
                ResLoader.Init("");
                BDebug.Log("资源加载:AssetDataBase editor only");
#endif
            }
            else
            {
                var path = "";
                if (Application.isEditor)
                {
                    if (!string.IsNullOrEmpty(customRoot))
                    {
                        path = customRoot;
                    }
                    else
                    {
                        if (loadPath == AssetLoadPath.Persistent)
                        {
                            path = Application.persistentDataPath;
                        }
                        else if (loadPath == AssetLoadPath.StreamingAsset)
                        {
                            path = Application.streamingAssetsPath;
                        }
                    }
                }
                else
                {
                    //真机环境config在persistent,跟dll和db保持一致
                    path = Application.persistentDataPath;
                }
                //
                ResLoader = new AssetBundleMgrV2();
                ResLoader.Init(path);
            }
        }
Esempio n. 11
0
 /// <summary>
 /// 使用新的配置
 /// </summary>
 /// <param name="newConfig"></param>
 private void SetNewConfig(GameConfig newConfig)
 {
     //TODO 未来改成反射实现,暂时用这一版
     if (newConfig != null)
     {
         this.CodeRoot = (AssetLoadPath)newConfig.CodeRoot;
         this.SQLRoot  = (AssetLoadPath)newConfig.SQLRoot;
         this.ArtRoot  = (AssetLoadPath)newConfig.ArtRoot;
         //
         this.CodeRunMode = (HotfixCodeRunMode)newConfig.CodeRunMode;
         //ip相关
         this.FileServerUrl = newConfig.FileServerUrl;
         this.IsHotfix      = newConfig.IsHotfix;
         this.GateServerIp  = newConfig.GateServerIp;
         this.Port          = newConfig.Port;
         if (!Application.isEditor)
         {
             this.IsHotfix = this.IsNeedNet = true;
         }
     }
 }
Esempio n. 12
0
        /// <summary>
        /// 开始热更脚本逻辑
        /// </summary>
        static public void Load(AssetLoadPath loadPath, HotfixCodeRunMode runMode)
        {
            if (loadPath == AssetLoadPath.Editor)
            {
                BDebug.Log("内置code模式!");
                //反射调用,防止编译报错
                var assembly = Assembly.GetExecutingAssembly();
                var type     = assembly.GetType("BDLauncherBridge");
                var method   = type.GetMethod("Start", BindingFlags.Public | BindingFlags.Static);
                method.Invoke(null, new object[] { false, false });
            }
            else
            {
                var path = "";
                if (Application.isEditor)
                {
                    if (loadPath == AssetLoadPath.Persistent)
                    {
                        path = Path.Combine(Application.persistentDataPath, BDApplication.GetPlatformPath(Application.platform));
                    }
                    else if (loadPath == AssetLoadPath.StreamingAsset)
                    {
                        path = Path.Combine(Application.streamingAssetsPath, BDApplication.GetPlatformPath(Application.platform));
                    }
                }
                else
                {
                    //真机环境,代码在persistent下,因为需要io
                    path = Path.Combine(Application.persistentDataPath, BDApplication.GetPlatformPath(Application.platform));
                }

                //加载dll
                var dllPath = Path.Combine(path, DLLPATH);
                LoadDLL(dllPath, runMode);
            }
        }
Esempio n. 13
0
		public AssetAsyncLoader(AssetLoadPath[] loadAssetPaths)
		{
			this.assetLoads = new List<AssetData>();
			this.loadAssetPaths = loadAssetPaths;
		}
Esempio n. 14
0
		public SceneTransition(string[] loadSceneNames, AssetLoadPath[] loadAssetPaths)
		{
			sceneLoader = new SceneAsyncLoader(loadSceneNames);
			assetLoader = new AssetAsyncLoader(loadAssetPaths);
		}