计算机网站开发要考什么证网站文章怎么做才能被收录
news/
2025/10/6 12:18:37/
文章来源:
计算机网站开发要考什么证,网站文章怎么做才能被收录,网站开发资讯,用易语言做抢购网站软件下载目录
一、准备工作
1.环境相关
2.Unity中配置
二、热更新
1.创建 HotUpdate 热更新模块
2.安装和配置HybridCLR
3.配置PlayerSettings
4.创建热更新相关脚本
5.打包dll
6.测试热更新 一、准备工作
1.环境相关
安装git环境。Win下需要安装visual studio 2019或更高版…目录
一、准备工作
1.环境相关
2.Unity中配置
二、热更新
1.创建 HotUpdate 热更新模块
2.安装和配置HybridCLR
3.配置PlayerSettings
4.创建热更新相关脚本
5.打包dll
6.测试热更新 一、准备工作
1.环境相关
安装git环境。Win下需要安装visual studio 2019或更高版本。安装时至少要包含 使用Unity的游戏开发 和 使用c的游戏开发 组件。 本文涉及到的Unity版本是2022.3.14f1c1。unity模块必须安装 Windows端Windows Build Support(IL2CPP)或Mac端Mac Build Support(IL2CPP)
2.Unity中配置
在unity中创建场景main并配置好脚本ConsoleToScreen.cs它可以打印日志到屏幕上方便定位错误。
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class ConsoleToScreen : MonoBehaviour
{const int maxLines 50;const int maxLineLength 120;private string _logStr ;private readonly Liststring _lines new Liststring();public int fontSize 15;void OnEnable() { Application.logMessageReceived Log; }void OnDisable() { Application.logMessageReceived - Log; }public void Log(string logString, string stackTrace, LogType type){foreach (var line in logString.Split(\n)){if (line.Length maxLineLength){_lines.Add(line);continue;}var lineCount line.Length / maxLineLength 1;for (int i 0; i lineCount; i){if ((i 1) * maxLineLength line.Length){_lines.Add(line.Substring(i * maxLineLength, maxLineLength));}else{_lines.Add(line.Substring(i * maxLineLength, line.Length - i * maxLineLength));}}}if (_lines.Count maxLines){_lines.RemoveRange(0, _lines.Count - maxLines);}_logStr string.Join(\n, _lines);}void OnGUI(){GUI.matrix Matrix4x4.TRS(Vector3.zero, Quaternion.identity,new Vector3(Screen.width / 1200.0f, Screen.height / 800.0f, 1.0f));GUI.Label(new Rect(10, 10, 800, 370), _logStr, new GUIStyle() { fontSize Math.Max(10, fontSize) });}}在Build Settings中添加main场景到打包场景列表。
二、热更新
1.创建 HotUpdate 热更新模块
创建 Assets/HotUpdate 目录目录名称不做要求可随便起在HotUpdate 目录下右键 Create/Assembly Definition创建一个名为HotUpdate名称不做要求的程序集模块。 当自己创建一个新的程序集定义文件.asmdef时该文件所在目录以及其子目录下的所有C#脚本都会被默认包含进这个新的程序集中。但是如果子目录下有另一个.asmdef文件则那个子目录将会成为另一个独立的程序集。 2.安装和配置HybridCLR
主菜单中点击Windows/Package Manager打开包管理器。点击Add package from git URL...填入https://gitee.com/focus-creative-games/hybridclr_unity.git 或 https://github.com/focus-creative-games/hybridclr_unity.git。打开菜单HybridCLR/Installer... 点击安装按钮进行安装。安装完成后会在最后打印 安装成功日志。 配置HybridCLR打开菜单ProjectSetting / HybridCLR Settings 在Hot Update Assemblies配置项中添加HotUpdate程序集。 3.配置PlayerSettings
如果你用的hybridclr包低于v4.0.0版本需要关闭增量式GC(Use Incremental GC) 选项Scripting Backend 切换为 IL2CPPApi Compatability Level 切换为 .Net 4.x(Unity 2019-2020) 或 .Net FrameworkUnity 2021 4.创建热更新相关脚本
创建 Assets/HotUpdate/Hello.cs 文件该文件用于测试是否热更新
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Hello : MonoBehaviour
{public static void Run(){Debug.Log(Hello, HybridCLR, V1.0.0);}
}创建Assets/LoadDll.cs脚本用来加载热更新程序集
using HybridCLR;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Networking;public class LoadDll : MonoBehaviour
{void Start(){// Editor环境下HotUpdate.dll.bytes已经被自动加载不需要加载重复加载反而会出问题。
#if !UNITY_EDITORAssembly hotUpdateAss Assembly.Load(File.ReadAllBytes(${Application.streamingAssetsPath}/HotUpdate.dll.bytes));
#else// Editor下无需加载直接查找获得HotUpdate程序集Assembly hotUpdateAss System.AppDomain.CurrentDomain.GetAssemblies().First(a a.GetName().Name HotUpdate);
#endif//通过反射来调用热更新代码Type type hotUpdateAss.GetType(Hello);if (type null){Debug.Log(Hello assembly is null);}else{type.GetMethod(Run).Invoke(null, null);}}
}HybridCLR是原生运行时实现因此调用Assembly Assembly.Load(byte[])即可加载热更新程序集。为了简化演示我们不通过http服务器下载HotUpdate.dll而是直接将HotUpdate.dll放到StreamingAssets目录下
5.打包dll 如果配置正确Editor运行和打包后运行的效果一样。
运行菜单 HybridCLR/Generate/All 进行必要的生成操作。将{proj}/HybridCLRData/HotUpdateDlls/StandaloneWindows64(MacOS下为StandaloneMacXxx)目录下的HotUpdate.dll复制到Assets/StreamingAssets/HotUpdate.dll.bytes注意要加.bytes后缀。 打开Build Settings对话框点击Build And Run打包并且运行热更新示例工程。 如果打包成功并且屏幕上显示 Hello, HybridCLR, V1.0.0表示热更新代码被顺利执行 6.测试热更新
修改Assets/HotUpdate/Hello.cs的Run函数中Debug.Log(Hello, HybridCLR, V1.0.0);代码改成Debug.Log(Hello, HybridCLR, V1.1.0);。运行菜单命令HybridCLR/CompileDll/ActiveBulidTarget重新编译热更新代码。将{proj}/HybridCLRData/HotUpdateDlls/StandaloneWindows64(MacOS下为StandaloneMacXxx)目录下的HotUpdate.dll复制为刚才的打包输出目录的 XXX_Data/StreamingAssets/HotUpdate.dll.bytes。重新运行程序会发现屏幕中显示Hello, HybridCLR, V1.1.0表示热更新代码生效了 三、官方文档
快速上手 | HybridCLR
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/929301.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!