如何对自己的Unity项目代码进行加密混淆?

在这里插入图片描述

加密混淆的目的是让不怀好意者更难对你的项目进行逆向工程,我们可以使用Obfuscator 插件.

该插件的好处是与Unity构建过程无缝链接源文件的内容保持不变,而混淆只针对于已编译的程序集


一、导入及配置

1.插件版本:Obfuscator 3.9.0+

2.在Unity项目工程文件中导入该插件

3.导入完成后,先把工程项目打包Build出来一遍,会适配Obfuscator插件

4.Build完成后,控制台会显示Obfuscation successful,说明适配已经完成了
在这里插入图片描述

5.在Editor\Beebyte\Obfuscator文件夹目录中会多出了一个ObfuscatorOptions的配置文件
在这里插入图片描述

6.选中ObfuscatorOptions文件,在Inspector中可看到它的配置信息面板
在这里插入图片描述


二、详细用法解释

在这里插入图片描述
1.Obfuscation Enabled勾选即启用混淆代码插件
2.Obfuscate development builds 勾选即在Unity Development Builds模式中启用

在这里插入图片描述
3.混淆所有程序集,由Unity构建过程创建的要模糊化的程序集列表,包含文件扩展名
4.需要混淆的程序集文件名称

在这里插入图片描述
需要混淆代码的部分,包括:类名、方法名、参数、字段、属性、事件

在这里插入图片描述
5.枚举常量的混淆
6.公开的Mono方法、公开的Mono字段、以及MonoBehaviour类名的混淆,MonoBehaviour类名的混淆目前仅可在PC、Mac、Linux中使用
7.添加Obfuscator版本特性,启用此功能可防止意外地多次混淆相同的DLL。如果你选择通过菜单选项手动混淆dll,特别推荐使用它。

在这里插入图片描述
8.设置混淆的细节级别。在弹出窗口中显示的细节级别。Detailed会将项目的混淆时间增加40%左右

在这里插入图片描述

9.上面都是一些混淆的属性,包括添加虚假的代码的参数,红圈内两个参数建议填写91和1,混淆的代码会呈现的是“[]”,在视觉上会是看到这种效果:
在这里插入图片描述

Add fake code(添加虚假代码):推荐使用,它会复制现有的方法,并以误导人们的方式巧妙地修改副本。虽会增加文件大小和增加混淆构建时间,但不会改变代码流。

10.需要添加跳过混淆的命名空间、类、unity方法
在这里插入图片描述

11.其他参数就不一一列举了,可根据英文意思推断出其用法


更深入的用法:(必须懂)

[Skip][SkipRename]的标注
1.在Unity中若有拖拽赋值的点击事件或Animation Clip方法,该方法需要标注[SkipRename]
在这里插入图片描述

2.所有的数据类需要注明[Skip]不然调用不到里面的属性

3.插件不会去混淆Plugins文件夹内的代码,若第三方插件失效的话,看看有没有放置到Plugins文件夹内

4.跳过命名空间递归:
在这里插入图片描述

当勾选时,所有的AAA的子命名空间也会被跳过

在这里插入图片描述

当不勾选时,所有的AAA的子命名空间不会被跳过
在这里插入图片描述


三、反编译工具:ILSpy、DotPeek

https://github.com/icsharpcode/ILSpy
https://www.jetbrains.com/decompiler

使用这些工具可对程序进行反编译,查看混淆的效果

  • 13
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
淘宝花钱买的最新版!需要的拿去! This asset obfuscates your code to make it harder for bad guys to reverse engineer your projects. Specifically designed for Unity, it seamlessly links in with its build process. The top priority of this package is to work straight out of the box with no extra steps required. While other obfuscators can stop a game from working, Beebyte's obfuscator looks for specific Unity related code that must be protected. The contents of your source files are unchanged, the obfuscation targets the compiled assembly. Features: - Supports IL2CPP - Supports Assembly Definition Files (Unity 2017.3+) - Removes Namespaces without any conflicts - Recognises Unity related code that must not be changed - Renames Classes (including MonoBehaviours) - Renames Methods - Renames Parameters - Renames Fields - Renames Properties - Renames Events - String literal obfuscation - Adds fake methods - Easy and extensive customisation using the Unity inspector window - Consistent name translations are possible across multiple builds and developers - Semantically secure cryptographic naming convention for renamed members The asset works for both Unity Free and Unity Pro version 4.2.0 onwards (including Unity 5 & 2017 & 2018). Build targets include Standalone, Android, iOS, WebGL, UWP. Other platforms are not guaranteed or supported but may become supported at a future date. IL2CPP builds are much harder to reverse engineer but strings and member information (class, method names etc) are visible in the global-metadata.dat file. Obfuscation will apply to this file adding further security. Why not complement your security with the Anti-Cheat Toolkit - a great third party asset. For more information about the Obfuscator, please see the FAQ
This asset obfuscates your code to make it harder for bad guys to reverse engineer your projects. Specifically designed for Unity, it seamlessly links in with its build process. The top priority of this package is to work straight out of the box with no extra steps required. While other obfuscators can stop a game from working, Beebyte's obfuscator looks for specific Unity related code that must be protected. The contents of your source files are unchanged, the obfuscation targets the compiled assembly. Features: - Supports IL2CPP - Supports Assembly Definition Files (Unity 2017.3+) - Removes Namespaces without any conflicts - Recognises Unity related code that must not be changed - Renames Classes (including MonoBehaviours) - Renames Methods - Renames Parameters - Renames Fields - Renames Properties - Renames Events - String literal obfuscation - Adds fake methods - Easy and extensive customisation using the Unity inspector window - Consistent name translations are possible across multiple builds and developers - Semantically secure cryptographic naming convention for renamed members The asset works for both Unity Free and Unity Pro version 4.2.0 onwards (including Unity 5 & 2017 & 2018). Build targets include Standalone, Android, iOS, WebGL, UWP. Other platforms are not guaranteed or supported but may become supported at a future date. IL2CPP builds are much harder to reverse engineer but strings and member information (class, method names etc) are visible in the global-metadata.dat file. Obfuscation will apply to this file adding further security. Why not complement your security with the Anti-Cheat Toolkit - a great third party asset. For more information about the Obfuscator, please see the FAQ
Unity项目代码规范是指在使用Unity引擎开发项目时,为了提高代码的可读性、可维护性和团队协作效率,制定的一系列规范和准则。它涵盖了命名规则、代码布局、注释规定、代码组织、代码风格等方面。 首先,命名规则是非常重要的,要遵循驼峰式命名法,清晰地表达变量和函数的用途,并避免使用过于简单或者过于复杂的命名。变量和函数名应该能够准确地描述其含义,以提高代码的可读性。 其次,在代码布局方面,应该保持适当的缩进和格式化,使得代码的层次结构清晰可见。函数之间应该留有空行来增加可读性。 另外,注释是帮助理解代码的重要工具,应该在关键的地方增加注释,解释代码的意图和使用方法。特别是对于复杂的算法或者不易理解的逻辑,需要详细的注释以方便其他开发人员阅读和维护代码代码组织方面,可以按照模块划分代码文件,每个脚本文件中只包含特定功能的代码,并避免一个脚本文件过于庞大和复杂。同时,使用合理的文件夹结构来组织项目文件,便于开发人员查找和管理相关文件。 最后,代码风格是统一团队开发的关键,可以采用统一的代码风格,如使用特定的缩进、符号的使用等。这样不仅可以提高代码的一致性,还能加快团队成员之间的沟通和协作。 总之,Unity项目代码规范能够提高项目的开发效率、代码的可读性和可维护性,帮助团队成员更好地理解和协作开发项目。通过制定和遵守代码规范,可以提高项目的质量和稳定性,同时也为后续的维护和更新工作奠定良好的基础。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mr.Y仙森

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值