/* * Does not set any local variables. Is safe to use to create duplicate physics worlds for independant simulation. */ public bool CreatePhysicsWorld(out CollisionWorld world, out CollisionConfiguration collisionConfig, out CollisionDispatcher dispatcher, out BroadphaseInterface broadphase, out SequentialImpulseConstraintSolver solver, out SoftBodyWorldInfo softBodyWorldInfo) { bool success = true; if (m_worldType == WorldType.SoftBodyAndRigidBody && m_collisionType == CollisionConfType.DefaultDynamicsWorldCollisionConf) { BDebug.LogError(debugType, "For World Type = SoftBodyAndRigidBody collisionType must be collisionType=SoftBodyRigidBodyCollisionConf. Switching"); m_collisionType = CollisionConfType.SoftBodyRigidBodyCollisionConf; success = false; } collisionConfig = null; if (m_collisionType == CollisionConfType.DefaultDynamicsWorldCollisionConf) { collisionConfig = new DefaultCollisionConfiguration(); } else if (m_collisionType == CollisionConfType.SoftBodyRigidBodyCollisionConf) { collisionConfig = new SoftBodyRigidBodyCollisionConfiguration(); } dispatcher = new CollisionDispatcher(collisionConfig); if (m_broadphaseType == BroadphaseType.DynamicAABBBroadphase) { broadphase = new DbvtBroadphase(); } else if (m_broadphaseType == BroadphaseType.Axis3SweepBroadphase) { broadphase = new AxisSweep3(m_axis3SweepBroadphaseMin.ToBullet(), m_axis3SweepBroadphaseMax.ToBullet(), axis3SweepMaxProxies); } else if (m_broadphaseType == BroadphaseType.Axis3SweepBroadphase_32bit) { broadphase = new AxisSweep3_32Bit(m_axis3SweepBroadphaseMin.ToBullet(), m_axis3SweepBroadphaseMax.ToBullet(), axis3SweepMaxProxies); } else { broadphase = null; } world = null; softBodyWorldInfo = null; solver = null; if (m_worldType == WorldType.CollisionOnly) { world = new CollisionWorld(dispatcher, broadphase, collisionConfig); } else if (m_worldType == WorldType.RigidBodyDynamics) { world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, collisionConfig); } else if (m_worldType == WorldType.MultiBodyWorld) { world = new MultiBodyDynamicsWorld(dispatcher, broadphase, null, collisionConfig); } else if (m_worldType == WorldType.SoftBodyAndRigidBody) { Solver = new SequentialImpulseConstraintSolver(); Solver.RandSeed = sequentialImpulseConstraintSolverRandomSeed; m_world = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf); _ddWorld = (DiscreteDynamicsWorld)m_world; SoftRigidDynamicsWorld _sworld = (SoftRigidDynamicsWorld)m_world; m_world.DispatchInfo.EnableSpu = true; _sworld.WorldInfo.SparseSdf.Initialize(); _sworld.WorldInfo.SparseSdf.Reset(); _sworld.WorldInfo.AirDensity = 1.2f; _sworld.WorldInfo.WaterDensity = 0; _sworld.WorldInfo.WaterOffset = 0; _sworld.WorldInfo.WaterNormal = BulletSharp.Math.Vector3.Zero; _sworld.WorldInfo.Gravity = m_gravity.ToBullet(); } if (world is DiscreteDynamicsWorld) { ((DiscreteDynamicsWorld)world).Gravity = m_gravity.ToBullet(); } if (_doDebugDraw) { DebugDrawUnity db = new DebugDrawUnity(); db.DebugMode = _debugDrawMode; world.DebugDrawer = db; } return(success); }
/// <summary> /// 开始任务 /// </summary> /// <param name="serverConfigPath">服务器配置根目录</param> /// <param name="localConfigPath">本地根目录</param> /// <param name="onProcess"></param> /// <param name="onError"></param> /// 返回码: -1:error 0:success static async public Task <int> Start(string serverConfigPath, string localConfigPath, Action <int, int> onProcess, Action <string> onError) { var client = HttpMgr.Inst.GetFreeHttpClient(); var platform = Utils.GetPlatformPath(Application.platform); //开始下载服务器配置 var serverPath = serverConfigPath + "/" + platform + "/" + platform + "_VersionConfig.json"; string serverConfig = ""; try { serverConfig = await client.DownloadStringTaskAsync(serverPath); BDebug.Log("服务器资源配置:" + serverConfig); } catch (Exception e) { onError(e.Message); return(-1); } var serverconf = LitJson.JsonMapper.ToObject <AssetConfig>(serverConfig); AssetConfig localconf = null; var localPath = localConfigPath + "/" + platform + "/" + platform + "_VersionConfig.json"; if (File.Exists(localPath)) { localconf = LitJson.JsonMapper.ToObject <AssetConfig>(File.ReadAllText(localPath)); } //对比差异列表进行下载 var list = CompareConfig(localConfigPath, localconf, serverconf); if (list.Count > 0) { //预通知要进入热更模式 onProcess(0, list.Count); } int count = 0; foreach (var item in list) { count++; var sp = serverConfigPath + "/" + platform + "/" + item.HashName; var lp = localConfigPath + "/" + platform + "/" + item.LocalPath; //创建目录 var direct = Path.GetDirectoryName(lp); if (Directory.Exists(direct) == false) { Directory.CreateDirectory(direct); } //下载 try { await client.DownloadFileTaskAsync(sp, lp); } catch (Exception e) { BDebug.LogError(sp); onError(e.Message); return(-1); } BDebug.Log("下载成功:" + sp); onProcess(count, list.Count); } //写到本地 if (list.Count > 0) { File.WriteAllText(localPath, serverConfig); } else { BDebug.Log("可更新数量为0"); } return(0); }
protected virtual void OnDestroy() { BDebug.Log(debugType, "Destroying Physics World"); Dispose(false); }
/// <summary> /// 打包APK /// </summary> static public void BuildAPK(BuildMode mode) { if (!BDFrameEditorConfigHelper.EditorConfig.IsSetConfig()) { BDebug.LogError("请注意设置apk keystore账号密码"); return; } var absroot = Application.dataPath.Replace("Assets", ""); PlayerSettings.Android.keystoreName = absroot + BDFrameEditorConfigHelper.EditorConfig.Android.keystoreName; PlayerSettings.keystorePass = BDFrameEditorConfigHelper.EditorConfig.Android.keystorePass; PlayerSettings.Android.keyaliasName = BDFrameEditorConfigHelper.EditorConfig.Android.keyaliasName; PlayerSettings.keyaliasPass = BDFrameEditorConfigHelper.EditorConfig.Android.keyaliasPass; //具体安卓的配置 PlayerSettings.gcIncremental = true; PlayerSettings.stripEngineCode = false; PlayerSettings.Android.preferredInstallLocation = AndroidPreferredInstallLocation.Auto; // var outdir = BDApplication.ProjectRoot + "/Build"; var outputPath = IPath.Combine(outdir, Application.productName + ".apk"); //文件夹处理 if (!Directory.Exists(outdir)) { Directory.CreateDirectory(outdir); } if (File.Exists(outputPath)) { File.Delete(outputPath); } //清空StreamingAsset var ios = IPath.Combine(Application.streamingAssetsPath, "iOS"); if (Directory.Exists(ios)) { Directory.Delete(ios, true); } var win = IPath.Combine(Application.streamingAssetsPath, "Windows"); if (Directory.Exists(win)) { Directory.Delete(win, true); } //开始项目一键打包 string[] scenes = { SCENEPATH }; BuildOptions opa = BuildOptions.None; if (mode == BuildMode.Debug) { opa = BuildOptions.CompressWithLz4HC | BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler | BuildOptions.EnableDeepProfilingSupport; } else if (mode == BuildMode.Release) { opa = BuildOptions.CompressWithLz4HC; } UnityEditor.BuildPipeline.BuildPlayer(scenes, outputPath, BuildTarget.Android, opa); if (File.Exists(outputPath)) { Debug.Log("Build Success :" + outputPath); EditorUtility.RevealInFinder(outputPath); } else { Debug.LogError(new Exception("Build Fail! Please Check the log! ")); } }
/// <summary> /// 开始任务 /// </summary> /// <param name="serverConfigPath">服务器配置根目录</param> /// <param name="localConfigPath">本地根目录</param> /// <param name="onProcess"></param> /// <param name="onError"></param> /// 返回码: -1:error 0:success static private IEnumerator IE_Start(UpdateMode mode, string serverConfigPath, string localConfigPath, Action <int, int> onProcess, Action <string> onError) { localConfigRootPath = localConfigPath; var platform = BApplication.GetPlatformPath(Application.platform); if (curDownloadList == null || curDownloadList.Count == 0) { //开始下载服务器配置 var serverPath = serverConfigPath + "/" + platform + "/" + platform + "_VersionConfig.json"; BDebug.Log("server:" + serverPath); //下载config { var wr = UnityWebRequest.Get(serverPath); yield return(wr.SendWebRequest()); if (wr.error == null) { serverConfig = wr.downloadHandler.text; BDebug.Log("服务器资源配置:" + serverConfig); } else { Debug.LogError(wr.error); } } var serverconf = LitJson.JsonMapper.ToObject <AssetConfig>(serverConfig); AssetConfig localconf = null; var localPath = string.Format("{0}/{1}/{2}_VersionConfig.json", localConfigPath, platform, platform); if (File.Exists(localPath)) { localconf = LitJson.JsonMapper.ToObject <AssetConfig>(File.ReadAllText(localPath)); } //对比差异列表进行下载 //不同模式生成不同下载列表 switch (mode) { case UpdateMode.CompareVersionConfig: curDownloadList = CompareVersionConfig(localconf, serverconf); break; case UpdateMode.Repair: curDownloadList = Repair(localconf, serverconf); break; } if (curDownloadList.Count > 0) { //预通知要进入热更模式 onProcess(0, curDownloadList.Count); } } while (curDonloadIndex < curDownloadList.Count) { var item = curDownloadList[curDonloadIndex]; var sp = serverConfigPath + "/" + platform + "/" + item.HashName; var lp = localConfigPath + "/" + platform + "/" + item.LocalPath; //创建目录 var direct = Path.GetDirectoryName(lp); if (Directory.Exists(direct) == false) { Directory.CreateDirectory(direct); } //下载 var wr = UnityWebRequest.Get(sp); yield return(wr.SendWebRequest()); if (wr.error == null) { File.WriteAllBytes(lp, wr.downloadHandler.data); BDebug.Log("下载成功:" + sp); onProcess(curDonloadIndex, curDownloadList.Count - 1); } else { BDebug.LogError("下载失败:" + wr.error); onError(wr.error); yield break; } //自增 curDonloadIndex++; } //写到本地 if (curDownloadList.Count > 0) { File.WriteAllText(string.Format("{0}/{1}/{2}_VersionConfig.json", localConfigPath, platform, platform), serverConfig); } else { BDebug.Log("不用更新"); onProcess(1, 1); } //重置 curDownloadList = null; curDonloadIndex = 0; serverConfig = null; }
/// <summary> /// 加载接口 /// </summary> /// <param name="configPath"></param> /// <param name="onLoaded"></param> public void Load(string configPath, string assetTypePath) { //资源类型配置 if (!string.IsNullOrEmpty(assetTypePath) && File.Exists(assetTypePath)) { var content = File.ReadAllText(assetTypePath); // var list = CsvSerializer.DeserializeFromString<List<string>>(content); // var wlist = new List<AssetTypes>() // { // new AssetTypes() // { // AssetTypeList = list, // } // }; // var str = CsvSerializer.SerializeToCsv(wlist); // File.WriteAllText(assetTypePath, str); // // // content = File.ReadAllText(assetTypePath); var records = CsvSerializer.DeserializeFromString <List <AssetTypes> >(content); this.AssetTypes = records[0]; //创建不同类型的映射表 foreach (var assetType in this.AssetTypes.AssetTypeList) { this.assetTypeIdxMap[assetType] = new LoadPathMap(); } } else { BDebug.LogError("配置文件不存在:" + configPath); } //资源配置 if (!string.IsNullOrEmpty(configPath) && File.Exists(configPath)) { this.configPath = configPath; #if UNITY_EDITOR Stopwatch sw = new Stopwatch(); sw.Start(); #endif var content = File.ReadAllText(configPath); this.AssetbundleItemList = CsvSerializer.DeserializeFromString <List <AssetBundleItem> >(content); #if UNITY_EDITOR sw.Stop(); BDebug.LogFormat("【AssetbundleV2】加载Config耗时{0}ms!", sw.ElapsedTicks / 10000L); #endif foreach (var abItem in this.AssetbundleItemList) { //可以被加载的资源 if (!string.IsNullOrEmpty(abItem.LoadPath) && this.AssetTypes != null) { var assettype = this.AssetTypes.AssetTypeList[abItem.AssetType]; var map = this.assetTypeIdxMap[assettype]; map[abItem.LoadPath] = abItem.Id; } } } else { BDebug.LogError("配置文件不存在:" + configPath); } //判断常用资源类型 if (this.AssetTypes != null) { var typecls = typeof(GameObject).FullName; this.TYPE_PREFAB = this.AssetTypes.AssetTypeList.FindIndex((at) => at == typecls); typecls = typeof(SpriteAtlas).FullName; this.TYPE_SPRITE_ATLAS = this.AssetTypes.AssetTypeList.FindIndex((at) => at == typecls); } if (this.AssetTypes != null && this.AssetbundleItemList.Count > 0) { BDebug.Log("【AssetbundleV2】资源加载初始化完成,资源数量:" + this.AssetbundleItemList.Count); } }
public void Do() { BDebug.Log("-------------这是demo2的 log---------", "yellow"); }
public void Start() { BDebug.Log("主工程代码启动!", "red"); }
public static void SetLocalPath(string path) { BDebug.Log(string.Format("设置加载路径为:{0}", path)); mAssetBundleMgr.LocalHotUpdateResPath = path; }
/// <summary> /// 主循环 /// </summary> void Update() { //停止所有携程 if (isStopAllCroutine) { BDebug.Log("停止所有携程"); StopAllCoroutines(); isStopAllCroutine = false; } //优先停止携程 while (stopIEIdQueue.Count > 0) { var id = stopIEIdQueue.Dequeue(); if (coroutineDictionary.ContainsKey(id)) { var coroutine = coroutineDictionary[id]; if (coroutine != null) { base.StopCoroutine(coroutine); } // coroutineDictionary.Remove(id); } else { Debug.LogErrorFormat("此id协程不存在,无法停止:{0}", id); } } //携程循环 if (IEnumeratorQueue.Count > 0) { var id = IEnumeratorQueue.Dequeue(); //取出携程 var ie = iEnumeratorDictionary[id]; iEnumeratorDictionary.Remove(id); //执行携程 var coroutine = base.StartCoroutine(ie); //存入coroutine coroutineDictionary[id] = coroutine; } //主线程循环 立即执行 while (actionTaskQueueImmediately.Count > 0) { var task = actionTaskQueueImmediately.Dequeue(); task.willDoAction(); if (task.callBackAction != null) { task.callBackAction(); } } //主线程循环 if (actionTaskQueue.Count > 0) { var task = actionTaskQueue.Dequeue(); task.willDoAction(); if (task.callBackAction != null) { task.callBackAction(); } } }
/// <summary> /// 分析资源 /// </summary> /// <param name="paths"></param> /// <param name="target"></param> /// <param name="outpath"></param> private static void AnalyzeResource(string[] paths, BuildTarget target, string outpath) { var lastConfigPath = IPath.Combine(outpath, "Art/Config.json"); if (File.Exists(lastConfigPath)) { curManifestConfig = new ManifestConfig(File.ReadAllText(lastConfigPath)); } else { curManifestConfig = new ManifestConfig(); } List <string> changeList = new List <string>(); float curIndex = 0; foreach (var path in paths) { var _path = path.Replace("\\", "/"); EditorUtility.DisplayProgressBar("分析资源 -" + target, "分析:" + Path.GetFileNameWithoutExtension(_path) + " 进度:" + curIndex + "/" + paths.Length, curIndex / paths.Length); curIndex++; var UIID = GetMD5HashFromFile(_path); if (string.IsNullOrEmpty(UIID)) { continue; } //获取被依赖的路径 var dependsource = "Assets" + _path.Replace(Application.dataPath, ""); var allDependObjectPaths = AssetDatabase.GetDependencies(dependsource).ToList(); dependsource = dependsource.ToLower(); // ManifestItem lastItem = null; curManifestConfig.Manifest.TryGetValue(dependsource, out lastItem); //last没有或者 uiid不一致被改动, //TODO 有改动的要把依赖重新打 if (lastItem != null && lastItem.UIID == UIID) { continue; } else { Debug.Log("打包:" + dependsource); } List <string> dependAssets = new List <string>(); //处理依赖资源打包 for (int i = 0; i < allDependObjectPaths.Count; i++) { // var dependPath = allDependObjectPaths[i]; //脚本不打包 var ext = Path.GetExtension(dependPath).ToLower(); if (ext == ".cs" || ext == ".js" || ext == ".dll") { continue; } // AssetImporter ai = AssetImporter.GetAtPath(dependPath); if (ai == null) { BDebug.Log("资源不存在:" + dependPath); continue; } var dependObjPath = Application.dataPath + dependPath.TrimStart("Assets".ToCharArray()); var uiid = GetMD5HashFromFile(dependObjPath); if (string.IsNullOrEmpty(uiid)) { continue; } string abname = "assets" + dependObjPath.Replace(Application.dataPath, "").ToLower(); ai.assetBundleName = abname; ai.assetBundleVariant = ""; //被依赖的文件,不保存其依赖信息 if (abname != dependsource) //依赖列表中会包含自己 { curManifestConfig.AddDepend(abname, uiid, new List <string>()); } dependAssets.Add(abname); } changeList.Add(dependsource); //保存主文件的依赖 if (dependAssets.Count > 0) { dependAssets.Remove(dependsource); curManifestConfig.AddDepend(dependsource, UIID, dependAssets); } } EditorUtility.ClearProgressBar(); Debug.Log("本地需要打包资源:" + changeList.Count); }
public void Start() { // Application.targetFrameRate = 24; BDebug.Log("hotfix代码 启动器连接成功!", "red"); }
/// <summary> /// 拷贝文件到Persistent下 /// </summary> /// <returns></returns> static private IEnumerator IECheckAssetPackageVersion(RuntimePlatform platform, Action callback) { var persistent = string.Format("{0}/{1}", Application.persistentDataPath, BDApplication.GetPlatformPath(platform)); var streamingAsset = string.Format("{0}/{1}", Application.streamingAssetsPath, BDApplication.GetPlatformPath(platform)); var persistentPackageInfoPath = string.Format("{0}/{1}", persistent, PackageBuildInfo); var streamingPackageinfoPath = string.Format("{0}/{1}", streamingAsset, PackageBuildInfo); WWW www = new WWW(streamingPackageinfoPath); yield return(www); if (www.error != null) { //不存在Streaming配置 callback?.Invoke(); yield break; } else { //判断版本 if (File.Exists(persistentPackageInfoPath)) { var content = File.ReadAllText(persistentPackageInfoPath); var persistentPackageInfo = JsonMapper.ToObject <PackageBuildInfo>(content); var streamingPackageInfo = JsonMapper.ToObject <PackageBuildInfo>(www.text); if (persistentPackageInfo.BuildTime >= streamingPackageInfo.BuildTime) { callback?.Invoke(); BDebug.Log("【资源包】不复制,persistent目录最新"); yield break; } else { BDebug.Log("【资源包】复制,Streaming包info更新"); //Streaming版本比较新 //复制Stream的packageinfo 到persistent FileHelper.WriteAllBytes(persistentPackageInfoPath, www.bytes); } } else { BDebug.Log("【资源包】第一次创建资源包info到persistent目录"); //persistent版本不存在 //复制Stream的packageinfo 到persistent FileHelper.WriteAllBytes(persistentPackageInfoPath, www.bytes); } } //复制新版本的DLL var persistentDLLPath = string.Format("{0}/{1}", persistent, ScriptLoder.DLLPATH); var streamingDLLPath = string.Format("{0}/{1}", streamingAsset, ScriptLoder.DLLPATH); www = new WWW(streamingDLLPath); yield return(www); if (www.error == null) { FileHelper.WriteAllBytes(persistentDLLPath, www.bytes); BDebug.Log("复制dll成功!"); } www = new WWW(streamingDLLPath + ".pdb"); yield return(www); if (www.error == null) { FileHelper.WriteAllBytes(persistentDLLPath + ".pdb", www.bytes); BDebug.Log("复制dll.pdb成功!"); } else { //删除persistent下的pdb防止跟dll不匹配 var pbdPath = persistentDLLPath + ".pdb"; if (File.Exists(pbdPath)) { File.Delete(pbdPath); } } //复制Sql var persistentSQLPath = string.Format("{0}/{1}", persistent, SqliteLoder.LOCAL_DB_PATH); var streamingSQLPath = string.Format("{0}/{1}", streamingAsset, SqliteLoder.LOCAL_DB_PATH); www = new WWW(streamingSQLPath); yield return(www); if (www.error == null) { FileHelper.WriteAllBytes(persistentSQLPath, www.bytes); BDebug.Log("复制db成功!"); } //复制ArtConfig var persistentArtConfigPath = string.Format("{0}/{1}", persistent, BResources.CONFIGPATH); var streamingArtConfigPath = string.Format("{0}/{1}", streamingAsset, BResources.CONFIGPATH); www = new WWW(streamingArtConfigPath); yield return(www); if (www.error == null) { FileHelper.WriteAllBytes(persistentArtConfigPath, www.bytes); BDebug.Log("复制artconfig成功!"); } callback?.Invoke(); yield return(null); }
/// <summary> /// 编译DLL /// </summary> static public void GenDllByMono(string dataPath, string outPath) { //这里是引入unity所有引用的dll #if UNITY_EDITOR_OSX var u3dUI = EditorApplication.applicationContentsPath + @"/UnityExtensions/Unity/GUISystem"; var u3dEngine = EditorApplication.applicationContentsPath + @"/Managed/UnityEngine"; #else var u3dUI = EditorApplication.applicationContentsPath + @"\UnityExtensions\Unity\GUISystem"; var u3dEngine = EditorApplication.applicationContentsPath + @"\Managed\UnityEngine"; #endif BDebug.Log(EditorApplication.applicationContentsPath); if (Directory.Exists(u3dUI) == false || Directory.Exists(u3dEngine) == false) { EditorUtility.DisplayDialog("提示", "u3d根目录不存在,请修改ScriptBiuld_Service类中,u3dui 和u3dengine 的dll目录", "OK"); return; } //编译项目的base.dll EditorUtility.DisplayProgressBar("编译服务", "准备编译dll", 0.1f); //准备工作 var path = outPath + "/Hotfix"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); string[] searchPath = new string[] { "3rdPlugins", "Code", "Plugins", "Resource" }; for (int i = 0; i < searchPath.Length; i++) { searchPath[i] = IPath.Combine(dataPath, searchPath[i]); } List <string> files = new List <string>(); foreach (var s in searchPath) { var fs = Directory.GetFiles(s, "*.*", SearchOption.AllDirectories).ToList(); var _fs = fs.FindAll(f => { var exten = Path.GetExtension(f).ToLower(); if (f.ToLower().Contains("editor") == false && (exten.Equals(".dll") || exten.Equals(".cs"))) { return(true); } return(false); }); files.AddRange(_fs); } files = files.Distinct().ToList(); for (int i = 0; i < files.Count; i++) { files[i] = files[i].Replace('\\', '/').Trim(); } EditorUtility.DisplayProgressBar("编译服务", "开始整理script", 0.2f); var refDlls = files.FindAll(f => f.EndsWith(".dll")); var baseCs = files.FindAll(f => !f.EndsWith(".dll") && !f.Contains("@hotfix")); var hotfixCs = files.FindAll(f => !f.EndsWith(".dll") && f.Contains("@hotfix")); #if UNITY_EDITOR_OSX var tempDirect = Application.persistentDataPath + "/bd_temp"; #else var tempDirect = "c:/bd_temp"; #endif if (Directory.Exists(tempDirect)) { Directory.Delete(tempDirect, true); } Directory.CreateDirectory(tempDirect); //除去不需要引用的dll for (int i = refDlls.Count - 1; i >= 0; i--) { var str = refDlls[i]; if (str.Contains("iOS") || str.Contains("Android")) { refDlls.RemoveAt(i); } } //去除同名 重复的dll for (int i = 0; i < refDlls.Count; i++) { var copyto = IPath.Combine(tempDirect, Path.GetFileName(refDlls[i])); File.Copy(refDlls[i], copyto, true); refDlls[i] = copyto; } refDlls.Add("System.dll"); refDlls.Add("System.Core.dll"); refDlls.Add("System.XML.dll"); refDlls.Add("System.Data.dll"); //dll1 var u3ddlls1 = Directory.GetFiles(u3dUI, "*.dll", SearchOption.TopDirectoryOnly); foreach (var d in u3ddlls1) { refDlls.Add(d); } //dll2 var u3ddlls2 = Directory.GetFiles(u3dEngine, "*.dll", SearchOption.AllDirectories); foreach (var d in u3ddlls2) { refDlls.Add(d); } // var baseDllPath = outPath + "/hotfix/base.dll"; EditorUtility.DisplayProgressBar("编译服务", "复制编译代码", 0.3f); //为解决mono.exe error: 文件名太长问题 //全部拷贝到临时目录 for (int i = 0; i < baseCs.Count; i++) { var copyto = IPath.Combine(tempDirect, Path.GetFileName(baseCs[i])); int count = 1; while (File.Exists(copyto)) { copyto = copyto.Replace(".cs", "") + count + ".cs"; count++; } File.Copy(baseCs[i], copyto); baseCs[i] = copyto.Replace("\\", "/"); } //建立目标目录 var outDirectory = Path.GetDirectoryName(baseDllPath); if (Directory.Exists(outDirectory)) { Directory.Delete(outDirectory, true); } // try { Directory.CreateDirectory(outDirectory); } catch (Exception e) { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("提示", "Unity拒绝创建文件夹,请重试!", "OK"); return; } EditorUtility.DisplayProgressBar("编译服务", "[1/2]开始编译base.dll", 0.4f); //编译 base.dll try { //转换shortname // for (int i = 0; i < baseCs.Count; i++) // { // var cs = baseCs[i]; // baseCs[i] = FileNameHelper.GetShortPath(cs); // } // Build(refDlls.ToArray(), baseCs.ToArray(), baseDllPath); AssetDatabase.Refresh(); } catch (Exception e) { Debug.LogError(e.Message); EditorUtility.ClearProgressBar(); throw; } // EditorUtility.DisplayProgressBar("编译服务", "[2/2]开始编译hotfix.dll", 0.7f); var dependent = outDirectory + "/dependent"; Directory.CreateDirectory(dependent); //将base.dll加入 refDlls.Add(baseDllPath); //编译hotfix.dll var outHotfixDirectory = outPath + "/hotfix/hotfix.dll"; try { //转换shortname // for (int i = 0; i < hotfixCs.Count; i++) // { // var cs = hotfixCs[i]; // hotfixCs[i] = FileNameHelper.GetShortPath(cs); // } Build(refDlls.ToArray(), hotfixCs.ToArray(), outHotfixDirectory); AssetDatabase.Refresh(); } catch (Exception e) { Debug.LogError(e.Message); EditorUtility.ClearProgressBar(); throw; } //拷贝依赖的dll // foreach (var f in refDlls) // { // if (File.Exists(f) ==false) // { // continue; // } // var fn = Path.GetFileName(f); // var outpath = IPath.Combine(dependent, fn); // File.Copy(f,outpath,true); // } EditorUtility.DisplayProgressBar("编译服务", "清理临时文件", 0.9f); Directory.Delete(tempDirect, true); EditorUtility.ClearProgressBar(); }
/// <summary> /// 核心功能,所有任务靠这个推进度 /// 执行下个任务 /// </summary> void DoNextTask() { if (isDoing) { return; } //没有东西的时候 跳出 if (currentTaskGroup == null && this.allTaskList.Count == 0) { BDebug.Log("---------无任务组,退出----------"); return; } else if (currentTaskGroup == null && this.allTaskList.Count > 0) { BDebug.Log("---------开始执行任务组----------"); currentTaskGroup = this.allTaskList[0]; } LoadTask task = null; //获取一个任务 for (;;) { task = currentTaskGroup.GetTask(); //task为空,或者任务可以执行,跳出 if (task == null || willDoTaskSet.Contains(task.Id)) { break; } } //当前任务组已经全部完成 if (task == null) { BDebug.Log("---------一组加载任务组已完成----------"); currentTaskGroup = null; this.allTaskList.RemoveAt(0); DoNextTask(); } else { // BDebug.Log("执行任务组中task:" + task.Id + " - " + task.ResourcePath); isDoing = true; //执行任务 AsyncLoadAssetBundle(task.ResourcePath, b => { //移除任务 this.willDoTaskSet.Remove(task.Id); // var path = "assets/resource/runtime/" + task.ResourcePath.ToLower() + "."; path = GetExistPath(path); var obj = LoadFormAssetBundle <Object>(path, path); //任务完成 currentTaskGroup.OnOneTaskComplete(task.Id, task.ResourcePath, obj); isDoing = false; //继续执行 DoNextTask(); }); } }
public void Start() { // Application.targetFrameRate = 24; BDebug.Log("热更启动成功!", "red"); IsAwake = true; }
/// <summary> /// 分析Props修改 /// </summary> /// <param name="transformBindData"></param> /// <param name="newProps"></param> /// <returns></returns> List <string> AnalysisPropsChanged(TransformBindData transformBindData, APropsBase newProps) { List <string> changedFiledList = new List <string>(); //手动设置field模式 if (newProps.IsMunalMarkMode) { if (newProps.IsChanged) { changedFiledList.AddRange(newProps.GetChangedPropertise()); } } else { //自动判断模式 foreach (var item in transformBindData.FieldCacheMap) { var fieldName = item.Key; var newFieldValue = newProps.GetValue(fieldName); //旧数据为null 直接加入 if (item.Value.LastValue == null) { item.Value.LastValue = newFieldValue; changedFiledList.Add(fieldName); continue; } bool isChanged = false; var newValueType = newFieldValue.GetType(); //开始新的对比判断 if (newValueType.IsValueType || newValueType.Namespace == "System") //内置类型处理 { if (!newProps.Equals(item.Value.LastValue)) { isChanged = true; } } else if (newFieldValue is APropsBase) //成员属性尽量使用手动版本设置改变 { var props = newFieldValue as APropsBase; if (props.IsMunalMarkMode) { if (props.IsChanged) { isChanged = true; } } else { //这里较慢,因为是全局列表更新 var transofrmdata = globalTransformBindCacheMap.Values.FirstOrDefault((v) => v.Props == props); if (transofrmdata == null) { isChanged = true; } else { //递归获取是否改变,一旦层数过多,效率不是很高,所以一般嵌套不要超过2层 var ret = AnalysisPropsChanged(transformBindData, props); if (ret.Count > 0) { isChanged = true; } } } } else if (newFieldValue is IPropsList) { var comList = newFieldValue as IPropsList; if (comList.IsChanged) { isChanged = true; } } else { BDebug.LogError("可能不支持的Props字段类型:" + newValueType.FullName); } if (isChanged) { changedFiledList.Add(fieldName); item.Value.LastValue = newFieldValue; } } } return(changedFiledList); }
/// <summary> /// 核心功能,所有任务靠这个推进度 /// 执行下个任务 /// </summary> void DoNextTask() { if (isDoing) { return; } //没有东西的时候 跳出 if (currentTaskGroup == null && this.allTaskList.Count == 0) { BDebug.Log("---------无任务组,退出----------"); return; } else if (currentTaskGroup == null && this.allTaskList.Count > 0) { currentTaskGroup = this.allTaskList[0]; BDebug.Log("---------开始执行任务组---------- |" + currentTaskGroup.GetHashCode()); foreach (var t in currentTaskGroup.TaskIdList) { BDebug.Log("--->" + t.ResourcePath); } } LoadTaskData taskData = null; //获取一个任务 while (true) { taskData = currentTaskGroup.GetTask(); //任务不存在当前可执行列表中 if (taskData != null && !willDoTaskSet.Contains(taskData.Id)) { currentTaskGroup.RemoveTask(taskData.Id); continue; } //task为空,或者任务可以执行,跳出 if (taskData == null || willDoTaskSet.Contains(taskData.Id)) { break; } } //当前任务组已经全部完成 if (taskData == null) { BDebug.Log("---------加载任务组已完成---------- |" + currentTaskGroup.GetHashCode()); currentTaskGroup = null; this.allTaskList.RemoveAt(0); DoNextTask(); } else { // BDebug.Log("执行任务组中task:" + taskData.Id + " - " + taskData.ResourcePath); isDoing = true; //执行任务 AsyncLoadAssetBundle(taskData.ResourcePath, b => { //移除任务 this.willDoTaskSet.Remove(taskData.Id); // var path = GetAssetRealPath(taskData.ResourcePath); var obj = LoadFormAssetBundle(path, taskData.LoadType); //任务完成 currentTaskGroup.OnOneTaskComplete(taskData.Id, taskData.ResourcePath, obj); isDoing = false; //继续执行 DoNextTask(); }); } }
/// <summary> /// 加载 /// 一般来说,主资源才需要load /// 依赖资源只要加载ab,会自动依赖 /// </summary> /// <param name="assetHash"></param> /// <param name="isLoadObj">是否需要返回加载资源</param> /// <param name="callback"></param> /// <returns></returns> IEnumerator IEAsyncLoadAssetbundle(string assetHash, bool isLoadObj, Action <LoadAssetState, Object> callback) { // var mainItem = config.Manifest.GetManifestItemByHash(assetHash); //单ab 多资源,加载真正ab名 if (mainItem != null && !string.IsNullOrEmpty(mainItem.Package)) { assetHash = mainItem.Package; } //正在被加载中,放入后置队列 if (lockSet.Contains(assetHash)) { callback(LoadAssetState.IsLoding, null); yield break; } //没被加载 if (!AssetbundleMap.ContainsKey(assetHash)) { AssetBundleCreateRequest ret = null; string fullpath = ""; //加锁 lockSet.Add(assetHash); { fullpath = FindAsset(assetHash); ret = AssetBundle.LoadFromFileAsync(fullpath); yield return(ret); } //解锁 lockSet.Remove(assetHash); //添加assetbundle if (ret.assetBundle != null) { AddAssetBundle(assetHash, ret.assetBundle); if (isLoadObj) { callback(LoadAssetState.Success, LoadFormAssetBundle <Object>(assetHash)); } else { callback(LoadAssetState.Success, null); } } else { callback(LoadAssetState.Fail, null); BDebug.LogError("ab资源为空:" + fullpath); } } else { if (isLoadObj) { callback(LoadAssetState.Success, LoadFormAssetBundle <Object>(assetHash)); } else { callback(LoadAssetState.Success, null); } } }
public void Do() { BDebug.Log("这是demo1的 log", "red"); }
/// <summary> /// 根据数据结构自动给Transform赋值 /// </summary> /// <param name="t"></param> /// <param name="o"></param> protected void AutoSetTranFormData(Transform t, object o) { var setList = new List <AutoSetValue>(t.GetComponentsInChildren <AutoSetValue>()); var type = o.GetType(); var fields = type.GetFields(); foreach (var f in fields) { //获取字段一致的节点 和属性名 var trans = setList.Find(s => s.name == f.Name); var fAttr = f.GetCustomAttribute <ValueType>(); if (trans != null && fAttr != null) { var component = trans.transform.GetComponent(fAttr.Type); if (component != null) { if (fAttr.Type == typeof(Text)) { var c = component as Text; c.text = f.GetValue(o).ToString(); } else if (fAttr.Type == typeof(Image)) { var c = component as Image; var path = f.GetValue(o).ToString(); c.sprite = BResources.Load <Sprite>(path); } else if (fAttr.Type == typeof(Slider)) { var c = component as Slider; var value = (float)f.GetValue(o); c.value = value; } else if (fAttr.Type == typeof(Scrollbar)) { var c = component as Scrollbar; var value = (float)f.GetValue(o); c.value = value; } else if (fAttr.Type == typeof(Toggle)) { var c = component as Toggle; var value = (bool)f.GetValue(o); c.isOn = value; } // else { BDebug.LogError("不支持类型,请扩展:" + f.Name + "-" + type.FullName); } } else { BDebug.LogError("字段标签错误:" + f.Name + "-" + type.FullName); } } else { BDebug.LogError("无同名节点 或者无标签:" + f.Name + "-" + type.FullName); } } }
public override void Init() { base.Init(); //提示 // var isCodeHotfix = GameObject.Find("BDFrame").GetComponent<BDLauncher>().IsCodeHotfix; // text_hotfixState.text = isCodeHotfix ? "热更模式:开" : "热更模式:关"; //demo1: screenview 切换 //代码: //Game@hotfix/demo1 this.btn_01.onClick.AddListener(() => { ScreenViewManager.Inst.MainLayer.BeginNavTo("demo1"); }); //demo2: ui window基本操作 //代码: //Game@hotfix/demo2 this.btn_02.onClick.AddListener(() => { ScreenViewManager.Inst.MainLayer.BeginNavTo("demo2"); //向demo2窗口发消息 var d = WindowData.Create("rotation"); d.AddData("rotation", UnityEngine.Random.Range(-359, 359)); UIManager.Inst.SendMessage((int)WinEnum.Win_Demo2, d); }); //demo3: uimvc模式 //代码: //Game@hotfix/demo3 this.btn_03.onClick.AddListener(() => { ScreenViewManager.Inst.MainLayer.BeginNavTo("demo3"); }); //demo4: uitools使用 //代码: //Game@hotfix/demo4 this.btn_04.onClick.AddListener(() => { UIManager.Inst.LoadWindows((int)WinEnum.Win_Demo4); UIManager.Inst.ShowWindow((int)WinEnum.Win_Demo4); }); //demo5: sqlite 查询 this.btn_05.onClick.AddListener(() => { var ds = SqliteHelper.DB.GetTableRuntime().Where("id > 1").ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } }); //demo6:资源加载 this.btn_06.onClick.AddListener(() => { //1.同步加载 var go = BResources.Load <GameObject>("Windows/window_demo1"); //2.异步加载单个 var id = BResources.AsyncLoad <GameObject>("Windows/window_demo1", (b, o) => { }); //3.异步加载多个 BResources.AsyncLoad(new List <string>() { "Windows/window_demo1", "Windows/window_demo2" }, (i, i2) => { Debug.Log(string.Format("进度 {0} / {1}", i, i2)); }, (map) => { BDebug.Log("加载全部完成,资源列表:"); foreach (var r in map) { BDebug.Log(string.Format("--> {0} : {1}", r.Key, r.Value.name)); GameObject.Instantiate(r.Value); } }); }); //代码: //Game@hotfix/demo_Manager_AutoRegister_And_Event this.btn_07.onClick.AddListener(() => { var path = Application.streamingAssetsPath; VersionContorller.Start(UpdateMode.Repair, "http://127.0.0.1", path, (i, j) => { Debug.LogFormat("资源更新进度:{0}/{1}", i, j); }, (error) => { Debug.LogError("错误:" + error); }); }); this.btn_08.onClick.AddListener(() => { DemoEventManager.Inst.Do(DemoEventEnum.TestEvent2); }); }
private void Awake() { Debug.Log("start bdframe"); //组件加载 this.gameObject.AddComponent <IEnumeratorTool>(); this.gameObject.AddComponent <BResources>(); Type[] frameTypes = Assembly.GetExecutingAssembly().GetTypes();; Type[] logicTypes = null; List <Type> allTypes = new List <Type>(); //编辑器环境下 寻找dll if (IsHotUpdate == false) { Debug.Log("非热更模式"); var assmblies = new List <Assembly>(AppDomain.CurrentDomain.GetAssemblies()); var logicAssmbly = assmblies.Find((a) => a.GetName().Name == "Assembly-CSharp"); logicTypes = logicAssmbly.GetTypes(); } else { } allTypes.AddRange(frameTypes); allTypes.AddRange(logicTypes); //其他环境用热更模型进行加载 // mgrList = new List <IMgr>(); //寻找所有的管理器 foreach (var t in allTypes) { if (t.BaseType != null && t.BaseType.GetInterface("IMgr") != null) { BDebug.Log("加载管理器-" + t, "green"); var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as IMgr; mgrList.Add(i); } //游戏启动器 else if (this.gameStart == null && t.GetInterface("IGameStart") != null) { gameStart = Activator.CreateInstance(t) as IGameStart; } } //类型注册 foreach (var t in allTypes) { foreach (var iMgr in mgrList) { iMgr.CheckType(t); } } //管理器唤醒 foreach (var _imgr in mgrList) { _imgr.Awake(); } if (gameStart != null) { gameStart.Awake(); } }
public override void Init() { base.Init(); //提示 // var isCodeHotfix = GameObject.Find("BDFrame").GetComponent<BDLauncher>().IsCodeHotfix; // text_hotfixState.text = isCodeHotfix ? "热更模式:开" : "热更模式:关"; //demo1: screenview 切换 //代码: //Game@hotfix/demo1 this.btn_01.onClick.AddListener(() => { ScreenViewManager.Inst.MainLayer.BeginNavTo(ScreenViewEnum.Demo1); }); //demo2: ui window基本操作 //代码: //Game@hotfix/demo2 this.btn_02.onClick.AddListener(() => { ScreenViewManager.Inst.MainLayer.BeginNavTo(ScreenViewEnum.Demo2); //向demo2窗口发消息 var d = WindowData.Create("rotation"); d.AddData("rotation", UnityEngine.Random.Range(-359, 359)); UIManager.Inst.SendMessage((int)WinEnum.Win_Demo2, d); }); //demo3: uitools使用 //代码: //Game@hotfix/demo4 this.btn_03.onClick.AddListener(() => { UIManager.Inst.LoadWindows((int)WinEnum.Win_Demo4); UIManager.Inst.ShowWindow((int)WinEnum.Win_Demo4); }); //demo4 : uflux窗口 //代码: this.btn_04.onClick.AddListener(() => { BDFramework.UFlux.UIManager.Inst.LoadWindow(UFluxWindowEnum.UFluxDemoMain); BDFramework.UFlux.UIManager.Inst.ShowWindow(UFluxWindowEnum.UFluxDemoMain); }); //demo5: sqlite 查询 this.btn_05.onClick.AddListener(() => { //单条件查询 Debug.Log("普通查询:"); var ds = SqliteHelper.DB.GetTableRuntime().Where("id = 1").ToSearch <Hero>(); ds = SqliteHelper.DB.GetTableRuntime().Where("id = {0}", 1).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //多条件查询 Debug.Log("多条件查询:"); ds = SqliteHelper.DB.GetTableRuntime().Where("id > 1").Where("and id < 3").ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //批量查询 Debug.Log("Where or 批量查询:"); ds = SqliteHelper.DB.GetTableRuntime().WhereAnd("id", "=", 1, 2).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //批量查询 Debug.Log("Where and 批量查询:"); ds = SqliteHelper.DB.GetTableRuntime().WhereOr("id", "=", 2, 3).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } }); //demo6:资源加载 this.btn_06.onClick.AddListener(() => { //1.同步加载 var go = BResources.Load <GameObject>("Test/Cube"); GameObject.Instantiate(go).name = "load"; //2.异步加载单个 var id = BResources.AsyncLoad <GameObject>("Windows/window_demo1", (o) => { }); //3.异步加载多个 var list = new System.Collections.Generic.List <string>() { "Windows/window_demo1", "Windows/window_demo2" }; BResources.AsyncLoad(list, (i, i2) => { Debug.Log(string.Format("进度 {0} / {1}", i, i2)); }, (map) => { BDebug.Log("加载全部完成,资源列表:"); foreach (var r in map) { BDebug.Log(string.Format("--> {0} : {1}", r.Key, r.Value.name)); GameObject.Instantiate(r.Value); } }); }); //代码: //Game@hotfix/demo_Manager_AutoRegister_And_Event this.btn_07.onClick.AddListener(() => { var path = Application.persistentDataPath; VersionContorller.Start(UpdateMode.Repair, "http://127.0.0.1", path, (i, j) => { Debug.LogFormat("资源更新进度:{0}/{1}", i, j); }, (error) => { Debug.LogError("错误:" + error); }); }); //发送消息机制 this.btn_08.onClick.AddListener(() => { DemoEventManager.Inst.Do(DemoEventEnum.TestEvent2); }); //图集 this.btn_09.onClick.AddListener(() => { UIManager.Inst.CloseWindow(WinEnum.Win_Main); UIManager.Inst.LoadWindows((int)WinEnum.Win_Demo5_Atlas); UIManager.Inst.ShowWindow((int)WinEnum.Win_Demo5_Atlas); }); }
/// <summary> /// 加载 /// </summary> /// <param name="source"></param> /// <param name="copyto"></param> /// <returns></returns> static IEnumerator IE_LoadScript(string root, HotfixCodeRunMode mode) { string dllPath = ""; if (Application.isEditor) { dllPath = root + "/" + BDUtils.GetPlatformPath(Application.platform) + "/Hotfix/hotfix.dll"; } else { //这里情况比较复杂,Mobile上基本认为Persistent才支持File操作, //可寻址目录也只有 StreamingAsset var firstPath = Application.persistentDataPath + "/" + BDUtils.GetPlatformPath(Application.platform) + "/Hotfix/hotfix.dll"; var secondPath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform) + "/Hotfix/hotfix.dll"; if (!File.Exists(firstPath)) { var www = new WWW(secondPath); yield return(www); if (www.isDone && www.error == null) { BDebug.Log("拷贝dll成功:" + firstPath); FileHelper.WriteAllBytes(firstPath, www.bytes); } } dllPath = firstPath; } //反射执行 if (mode == HotfixCodeRunMode.ByReflection) { BDebug.Log("Dll路径:" + dllPath, "red"); var bytes = File.ReadAllBytes(dllPath); var mdb = dllPath + ".mdb"; if (File.Exists(mdb)) { var bytes2 = File.ReadAllBytes(mdb); Assembly = Assembly.Load(bytes, bytes2); } else { Assembly = Assembly.Load(bytes); } BDebug.Log("代码加载成功,开始执行Start"); var type = Assembly.GetType("BDLauncherBridge"); var method = type.GetMethod("Start", BindingFlags.Public | BindingFlags.Static); method.Invoke(null, new object[] { false, true }); } //解释执行 else if (mode == HotfixCodeRunMode.ByILRuntime) { BDebug.Log("Dll路径:" + dllPath, "red"); //解释执行模式 ILRuntimeHelper.LoadHotfix(dllPath); ILRuntimeHelper.AppDomain.Invoke("BDLauncherBridge", "Start", null, new object[] { true, false }); } else { BDebug.Log("Dll路径:内置", "red"); } }
/// <summary> /// bind Tansform和State的值,防止每次都修改 /// </summary> /// <param name="t"></param> /// <param name="aState"></param> /// <returns></returns> private Dictionary <string, ComponentValueCahce> TransformStateBind(Transform t, AStateBase aState) { Dictionary <string, ComponentValueCahce> retMap = new Dictionary <string, ComponentValueCahce>(); //所有的成员信息 var memberInfos = StateFactory.GetCache(aState.GetType()); foreach (var mi in memberInfos.Values) { //先寻找节点 Transform transform = null; { var attrs = mi.GetCustomAttributes(typeof(TransformPath), false); if (attrs.Length > 0) { var attr = attrs[0] as TransformPath; transform = t.Find(attr.Path); if (!transform) { BDebug.LogError("节点不存在:" + attr.Path + " -" + aState.GetType().Name); continue; } } else { continue; } } //再进行值绑定 { ComponentValueCahce cvc = new ComponentValueCahce(); var attrType = typeof(ComponentValueBind); var attrs = mi.GetCustomAttributes(attrType, false); // if (attrs.Length > 0) //寻找ComponentValueBind { if (attrs[0] is ComponentValueBind) { var cvb = (ComponentValueBind)attrs[0]; if (cvb.Type.IsSubclassOf(typeof(UIBehaviour))) { cvc.UIBehaviour = transform.GetComponent(cvb.Type) as UIBehaviour; } else { cvc.Transform = transform; } cvc.ValueBind = cvb; } } else //如果只有Transform 没有ComponentValueBind标签,处理默认逻辑 { Type type = null; if (mi is FieldInfo) { type = ((FieldInfo)mi).FieldType; } else if (mi is PropertyInfo) { type = ((PropertyInfo)mi).PropertyType; } if (type.IsSubclassOf(typeof(PropsBase))) { //填充 子节点赋值逻辑 cvc.ValueBind = new ComponentValueBind(typeof(UFluxAutoLogic), nameof(UFluxAutoLogic.SetChildValue)); } else { cvc.ValueBind = new ComponentValueBind(typeof(UFluxAutoLogic), nameof(UFluxAutoLogic.ForeachSetChildValue)); #if UNITY_EDITOR //props 数组 if (type.IsArray && !type.GetElementType().IsSubclassOf(typeof(PropsBase))) //数组 { Debug.LogError("自动适配节点逻辑失败,类型元素不是Props!!!"); } //泛型 else if (type.IsGenericType && !type.GetGenericArguments()[0].IsSubclassOf(typeof(PropsBase))) //泛型 { Debug.LogError("自动适配节点逻辑失败,类型元素不是Props!!!"); } #endif //list t或者array if (type.IsArray || type.IsGenericType) //数组 { cvc.ValueBind = new ComponentValueBind(typeof(UFluxAutoLogic), nameof(UFluxAutoLogic.ForeachSetChildValue)); } } cvc.Transform = transform; } //缓存 retMap[mi.Name] = cvc; } } return(retMap); }
public override void Init() { base.Init(); //增加覆盖测试 var service = DataListenerServer.Create(nameof(DataListenerEnum)); service.AddListener(DataListenerEnum.test, (o) => { Debug.Log(o.ToString()); }); //demo1: screenview 切换 //代码: //Game@hotfix/demo1 this.btn_01.onClick.AddListener(() => { ScreenViewManager.Inst.MainLayer.BeginNavTo(ScreenViewEnum.Demo1); }); //demo4 : uflux窗口 //代码: this.btn_04.onClick.AddListener(() => { //测试多个接口 var list = new List <int>() { (int)WinEnum.Win_Demo6 }; UIManager.Inst.AsyncLoadWindows(list, (i, j) => { //log BDebug.LogFormat("加载进度:{0}-{1}", i, j); UIManager.Inst.ShowWindow(WinEnum.Win_Demo6); }); }); //demo5: sqlite 查询 this.btn_05.onClick.AddListener(() => { //单条件查询 Debug.Log("普通查询:"); var ds = SqliteHelper.DB.GetTableRuntime().Where("id = 1").ToSearch <Hero>(); ds = SqliteHelper.DB.GetTableRuntime().Where("id = {0}", 1).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //多条件查询 Debug.Log("OR And查询:"); ds = SqliteHelper.DB.GetTableRuntime().Where("id > 1").And.Where("id < 3").ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } ds = SqliteHelper.DB.GetTableRuntime().Where("id = 1").Or.Where("id = 3").ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //批量查询 Debug.Log("Where or 批量查询:"); ds = SqliteHelper.DB.GetTableRuntime().WhereAnd("id", "=", 1, 2).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //批量查询 Debug.Log("Where and 批量查询:"); ds = SqliteHelper.DB.GetTableRuntime().WhereOr("id", "=", 2, 3).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } }); //demo6:资源加载 this.btn_06.onClick.AddListener(() => { List <GameObject> golist = new List <GameObject>(); //1.同步加载 var go = BResources.Load <GameObject>("AssetTest/Cube"); var load1 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("Test/Cube"); var load2 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("AssetTest/Particle"); var load3 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("Char/001"); var loadModel = GameObject.Instantiate(go); golist.Add(load1); golist.Add(load2); golist.Add(load3); golist.Add(loadModel); //2.异步加载单个 var id = BResources.AsyncLoad <GameObject>("Test/Cube", (o) => { var load4 = GameObject.Instantiate(o); golist.Add(load4); }); //3.异步加载多个 var list = new List <string>() { "AssetTest/Cube", "Test/Cube" }; BResources.AsyncLoad(list, (i, i2) => { Debug.Log(string.Format("进度 {0} / {1}", i, i2)); }, (map) => { BDebug.Log("加载全部完成,资源列表:"); foreach (var r in map) { BDebug.Log(string.Format("--> {0} : {1}", r.Key, r.Value.name)); var _go = GameObject.Instantiate(r.Value) as GameObject; golist.Add(_go); } }); IEnumeratorTool.WaitingForExec(5, () => { foreach (var _go in golist) { GameObject.Destroy(_go); } }); }); //代码: //Game@hotfix/demo_Manager_AutoRegister_And_Event this.btn_07.onClick.AddListener(() => { var path = Application.persistentDataPath; VersionContorller.Start(UpdateMode.Repair, "http://127.0.0.1", path, (i, j) => { Debug.LogFormat("资源更新进度:{0}/{1}", i, j); }, (error) => { Debug.LogError("错误:" + error); }); }); //发送消息机制 this.btn_08.onClick.AddListener(() => { DemoEventManager.Inst.Do(DemoEventEnum.TestEvent2); }); //图集 this.btn_09.onClick.AddListener(() => { UIManager.Inst.CloseWindow(WinEnum.Win_Main); UIManager.Inst.LoadWindow(WinEnum.Win_Demo5_Atlas); UIManager.Inst.ShowWindow(WinEnum.Win_Demo5_Atlas); }); //数据监听 this.btn_10.onClick.AddListener(() => { UIManager.Inst.LoadWindow(WinEnum.Win_Demo_Datalistener); UIManager.Inst.ShowWindow(WinEnum.Win_Demo_Datalistener); }); }
public void LoadManifestAsync(string path, Action <bool> callback) { BDebug.Log("res 模式不需要加载依赖"); }
protected virtual void _InitializePhysicsWorld() { _isDisposed = false; if (m_worldType == WorldType.SoftBodyAndRigidBody && m_collisionType == CollisionConfType.DefaultDynamicsWorldCollisionConf) { BDebug.LogError(debugType, "For World Type = SoftBodyAndRigidBody collisionType must be collisionType=SoftBodyRigidBodyCollisionConf. Switching"); m_collisionType = CollisionConfType.SoftBodyRigidBodyCollisionConf; } if (m_collisionType == CollisionConfType.DefaultDynamicsWorldCollisionConf) { CollisionConf = new DefaultCollisionConfiguration(); } else if (m_collisionType == CollisionConfType.SoftBodyRigidBodyCollisionConf) { CollisionConf = new SoftBodyRigidBodyCollisionConfiguration(); } Dispatcher = new CollisionDispatcher(CollisionConf); if (m_broadphaseType == BroadphaseType.DynamicAABBBroadphase) { Broadphase = new DbvtBroadphase(); } else if (m_broadphaseType == BroadphaseType.Axis3SweepBroadphase) { Broadphase = new AxisSweep3(m_axis3SweepBroadphaseMin.ToBullet(), m_axis3SweepBroadphaseMax.ToBullet(), axis3SweepMaxProxies); } else if (m_broadphaseType == BroadphaseType.Axis3SweepBroadphase_32bit) { Broadphase = new AxisSweep3_32Bit(m_axis3SweepBroadphaseMin.ToBullet(), m_axis3SweepBroadphaseMax.ToBullet(), axis3SweepMaxProxies); } else { Broadphase = null; } if (m_worldType == WorldType.CollisionOnly) { m_world = new CollisionWorld(Dispatcher, Broadphase, CollisionConf); _ddWorld = null; } else if (m_worldType == WorldType.RigidBodyDynamics) { m_world = new DiscreteDynamicsWorld(Dispatcher, Broadphase, null, CollisionConf); _ddWorld = (DiscreteDynamicsWorld)m_world; } else if (m_worldType == WorldType.MultiBodyWorld) { m_world = new MultiBodyDynamicsWorld(Dispatcher, Broadphase, null, CollisionConf); _ddWorld = (DiscreteDynamicsWorld)m_world; } else if (m_worldType == WorldType.SoftBodyAndRigidBody) { Solver = new SequentialImpulseConstraintSolver(); Solver.RandSeed = sequentialImpulseConstraintSolverRandomSeed; softBodyWorldInfo = new SoftBodyWorldInfo { AirDensity = 1.2f, WaterDensity = 0, WaterOffset = 0, WaterNormal = BulletSharp.Math.Vector3.Zero, Gravity = UnityEngine.Physics.gravity.ToBullet(), Dispatcher = Dispatcher, Broadphase = Broadphase }; softBodyWorldInfo.SparseSdf.Initialize(); m_world = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf); _ddWorld = (DiscreteDynamicsWorld)m_world; m_world.DispatchInfo.EnableSpu = true; softBodyWorldInfo.SparseSdf.Reset(); softBodyWorldInfo.AirDensity = 1.2f; softBodyWorldInfo.WaterDensity = 0; softBodyWorldInfo.WaterOffset = 0; softBodyWorldInfo.WaterNormal = BulletSharp.Math.Vector3.Zero; softBodyWorldInfo.Gravity = m_gravity.ToBullet(); } if (_ddWorld != null) { _ddWorld.Gravity = m_gravity.ToBullet(); } if (_doDebugDraw) { DebugDrawUnity db = new DebugDrawUnity(); db.DebugMode = _debugDrawMode; m_world.DebugDrawer = db; } //Add a BPhysicsWorldLateHelper component to call FixedUpdate lateUpdateHelper = GetComponent <BPhysicsWorldLateHelper>(); if (lateUpdateHelper == null) { lateUpdateHelper = gameObject.AddComponent <BPhysicsWorldLateHelper>(); } lateUpdateHelper.m_world = m_world; lateUpdateHelper.m_ddWorld = _ddWorld; lateUpdateHelper.m_physicsWorld = this; lateUpdateHelper.m__frameCount = 0; lateUpdateHelper.m_lastSimulationStepTime = 0; }
private static void AnalyzeResource(string[] paths, BuildTarget target, string outpath) { var configPath = IPath.Combine(outpath, "Art/Config.json"); if (File.Exists(configPath)) { var content = File.ReadAllText(configPath); manifestConfig = new ManifestConfig(content); } else { manifestConfig = new ManifestConfig(); } int counter = 0; float curIndex = 0; foreach (var path in paths) { var _path = path.Replace("\\", "/"); EditorUtility.DisplayProgressBar("分析资源 -" + target.ToString(), "分析:" + Path.GetFileNameWithoutExtension(_path) + " 进度:" + curIndex + "/" + paths.Length, curIndex / paths.Length); curIndex++; //获取被依赖的路径 var dependsource = "Assets" + _path.Replace(Application.dataPath, ""); var allDependObjectPaths = AssetDatabase.GetDependencies(dependsource).ToList(); var manifestItem = manifestConfig.GetManifestItem(dependsource.ToLower()); var Uiid = GetMD5HashFromFile(_path); // var isEquals = manifestItem != null && Uiid == manifestItem.UIID; List <string> newAssets = new List <string>(); //处理依赖资源是否打包 for (int i = 0; i < allDependObjectPaths.Count; i++) { // var dependPath = allDependObjectPaths[i]; //脚本不打包 var ext = Path.GetExtension(dependPath).ToLower(); if (ext == ".cs" || ext == ".js") { continue; } // AssetImporter ai = AssetImporter.GetAtPath(dependPath); if (ai == null) { BDebug.Log("not find Resource " + dependPath); continue; } //重新组建ab名字,带上路径名 dependPath = Path.GetFullPath(dependPath); dependPath = dependPath.Replace("\\", "/"); //根据是否相等,判断是否打包 if (isEquals) { //本次不打包 ai.assetBundleName = null; } else { //本次打包 string derictory = "assets" + dependPath.Replace(Application.dataPath, ""); ai.assetBundleName = derictory.ToLower(); newAssets.Add(ai.assetBundleName); ai.assetBundleVariant = ""; } } //将现在的目录结构替换配置中的 if (newAssets.Count > 0) { newAssets.Remove(dependsource.ToLower()); manifestConfig.AddDepend(dependsource.ToLower(), Uiid, newAssets); counter++; } } EditorUtility.ClearProgressBar(); Debug.Log("本地需要打包资源:" + counter); }