/// <summary> /// 脚本加载入口 /// </summary> /// <param name="loadPathTypeType"></param> /// <param name="runMode"></param> /// <param name="mainProjectTypes">UPM隔离了dll,需要手动传入</param> static public void Init(AssetLoadPathType loadPathTypeType, HotfixCodeRunMode runMode, Type[] mainProjectTypes, Action <bool> clrBindingAction) { CLRBindAction = clrBindingAction; if (loadPathTypeType == AssetLoadPathType.Editor) { BDebug.Log("【ScriptLaunch】Editor(非热更)模式!"); //反射调用,防止编译报错 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 { BDebug.Log("【ScriptLaunch】热更模式!"); var path = GameConfig.GetLoadPath(loadPathTypeType); path = Path.Combine(path, BApplication.GetRuntimePlatformPath()); //加载dll var dllPath = Path.Combine(path, DLL_PATH); LoadHotfixDLL(dllPath, runMode, mainProjectTypes); } }
/// <summary> /// 初始化 /// </summary> /// <param name="abModel"></param> /// <param name="callback"></param> static public void Init(AssetLoadPathType loadPathType) { BDebug.Log("【BResource】加载路径:" + loadPathType.ToString()); if (loadPathType == AssetLoadPathType.Editor) { #if UNITY_EDITOR //防止编译报错 ResLoader = new DevResourceMgr(); ResLoader.Init(""); #endif } else { var path = GameConfig.GetLoadPath(loadPathType); ResLoader = new AssetBundleMgrV2(); ResLoader.Init(path); } }
/// <summary> /// runtime下加载,只读 /// </summary> /// <param name="str"></param> static public void Init(AssetLoadPathType assetLoadPathTypeType) { Connection?.Dispose(); var path = GameConfig.GetLoadPath(assetLoadPathTypeType); //用当前平台目录进行加载 path = GetLocalDBPath(path, BApplication.RuntimePlatform); if (File.Exists(path)) { Connection = new SQLiteConnection(path, SQLiteOpenFlags.ReadOnly); BDebug.Log("DB加载路径:" + path, "red"); } else { Debug.LogError("DB不存在:" + path); } }
/// <summary> /// 初始化 /// </summary> /// <param name="abModel"></param> /// <param name="callback"></param> static public void Init(AssetLoadPathType loadPathType) { BDebug.Log("【BResource】加载路径:" + loadPathType.ToString()); if (loadPathType == AssetLoadPathType.Editor) { #if UNITY_EDITOR //防止编译报错 ResLoader = new DevResourceMgr(); ResLoader.Init(null, RuntimePlatform.WindowsEditor); #endif } else { var path = GameConfig.GetLoadPath(loadPathType); ResLoader = new AssetBundleMgrV2(); ResLoader.Init(path, BApplication.RuntimePlatform); } //初始化对象池 InitObjectPools(); }
/// <summary> /// 获取加载路径 /// </summary> /// <param name="assetLoadPathType"></param> static public string GetLoadPath(AssetLoadPathType assetLoadPathType) { var path = ""; //Editor下按照加载路径区分 if (Application.isEditor) { switch (assetLoadPathType) { case AssetLoadPathType.Persistent: path = Application.persistentDataPath; break; case AssetLoadPathType.Editor: case AssetLoadPathType.StreamingAsset: { path = Application.streamingAssetsPath; } break; case AssetLoadPathType.DevOpsPublish: { path = BApplication.DevOpsPublishAssetsPath; } break; } } else { //真机环境默认都在persistent下, //因为需要io.不在的各个模块会自行拷贝 path = Application.persistentDataPath; } return(path); }