Giter VIP home page Giter VIP logo

unityhidecodewithdll's Introduction

UnityHideCodeWithDLL

HideCodeWithDLL other can not see the code except decompiler suc

Untiy类库构建代替代码

Visual Studio构建类库给Unity用:

  1. 创建类库项目,此处暂时没找到一次项目创建多个dll文件的方法,即类似Unity中AssemblyDefinitionFile的自定义程序集功能。

    image

    ​ 图1-1

  2. 注意命名方式,生成的动态链接库会以改名字生成,注意这里的命名不同于命名空间,这里是程序集命名。 image

    ​ 图1-2

  3. 创建之后的会进入第一个类文件Class1,这里已经将命名空间改为项目的名称。 image

    ​ 图1-3

  4. 添加依赖项(添加Unity相关类库的依赖),在项目下拉框下,点击添加项目引用,会弹出一个浏览文件窗口,再定位到你电脑中Unity的类库的位置,如图1-5所示。

    image

    图1-4

    image

    图1-5

  5. 添加了依赖项之后就可以开始编写Mono脚本,添加UnityEngine的引用,撰写脚本,如图1-6。

image

​ 图1-6

  1. 生成解决方案,步骤为下图1-7,结果为图1-8。

image

​ 图1-7

image

图1-8

image

​ 图1-9

  1. 使用类库中的相关类。

image

图1-10

image

图1-11

  1. Inspector面板和运行结果。

image

图1-12

image

图1-13

在Unity项目中直接找到对应的类库使用:

  1. 构建相关的AssemblyDefinationFile文件控制相关的代码,我的文件结构如下:

image

​ 图2-1

  1. 在Unity项目中找到对应的DLL文件,将其拖入Unity中。

image

​ 图2-2

  1. 拖入项目后,还不能将DLL文件中的Mono脚本挂在场景中的GameObject上,此时要将源码和ADF文件删除。

image

​ 图2-3

  1. 将Mono脚本挂载在相关的脚本上。

image

​ 图2-4

image

​ 图2-5

  1. 运行游戏打印结果

image

​ 图2-6

总结:

1.经过推敲,如果是项目代码需要隐藏,可实施性不大,因为代码在不停的修改,不停的生成最新的DLL文件,即使是使用Unity自带的目前最新的Roslyn Compiler,直接将新生成的DLL文件放入工程以DLL的形式跑代码(上述方法二),也是一件很费时的事情。

2.此法最好隐藏代码是写一个插件,插件以DLL的形式引用、调用、甚至挂载在GameObject上。

*相关资料查询:*

DLL构建、隐藏代码

https://answers.unity.com/questions/1707814/how-to-hide-c-code-from-custom-package-for-distrib.html

https://www.jacksondunstan.com/articles/3052

https://answers.unity.com/questions/1078603/unity-editor-script-in-dll.html

https://www.youtube.com/watch?v=CPkO1Gek8XQ

ADF

https://blog.csdn.net/baidu_39447417/article/details/115151569

unityhidecodewithdll's People

Contributors

chosen-gjh avatar

Stargazers

 avatar  avatar Sefa Enes TAS avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.