简体   繁体   English

Unity:在2D游戏中动态更改代码

[英]Unity: Change code dynamically in 2D game

I would like to use Unity to create a 2D game . 我想使用Unity来创建2D游戏 I have already read through some tutorials but I couldn't really find an answer to my problem. 我已经看过一些教程,但是我找不到真正的答案。

As my game should be changeable by an admin (a person should be able to change textboxes and some content of the game before distributing it), I would like to adapt some code of the game outside the unity program to adapt the whole game . 由于我的游戏应可由管理员更改(一个人应该能够在分发游戏之前更改游戏的文本框和某些内容),因此我想在统一程序之外修改游戏的某些代码以适应整个游戏 Is it possible to do this? 是否有可能做到这一点? If yes, what is the starting point for doing this? 如果是,这样做的出发点是什么?

I basically know what to do in Unity but I haven't understand the full structure there yet. 我基本上知道在Unity中做什么,但是我还不了解那里的完整结构。

EDIT 编辑

Example: I create a game in which a user have to collect items falling down the sky. 示例:我创建了一个游戏,其中用户必须收集从天上掉下来的物品。 Those items are words by default. 这些项目默认为单词。 But those items should be adaptable, so that I can change the words' content eg outside the engine. 但是这些项目应该具有适应性,以便我可以更改单词的内容,例如在引擎外部。

im no Unity Developer neither an Game Developer. 我不是Unity开发人员,也不是游戏开发人员。
There are several approaches. 有几种方法。 First of all, use resources. 首先,利用资源。 You shouldn't encode the content of Textboxes in your Code. 您不应该在代码中对文本框的内容进行编码。 It could be saved in a Textfile or an XML File. 可以将其保存在文本文件或XML文件中。 Ingame you load the file and use a collection for the falling words. 在游戏中,您加载了文件并使用了一个收集词。
Other approach: Build an interface like "fallingWordGenerator", implement it as DLL, and load the DLL on startup ( Loading DLLs at runtime in C# ). 其他方法:构建类似“ fallingWordGenerator”的接口,将其实现为DLL,并在启动时加载DLL(在C#中在运行时加载DLL )。

Greetings 问候

Within Unity, You Can make use of thé AssetsBundle. 在Unity中,您可以使用AssetsBundle。 http://docs.unity3d.com/Manual/AssetBundlesIntro.html http://docs.unity3d.com/Manual/AssetBundlesIntro.html

You can package new codes files, scenes and other content that can be downloaded and integrated at runtime. 您可以打包新的代码文件,场景和其他内容,这些文件可以在运行时下载并集成。 It does need Unity knowledge, however. 但是,它确实需要Unity知识。

Unity is an application for programmers , designers and even artists . Unity是面向程序员,设计师甚至艺术家的应用程序。 you can create Editors inside you unity project so your game designer can change and adapt data of your games. 您可以在统一项目中创建编辑器,以便游戏设计师可以更改和调整游戏数据。 Search for Custom Editors inside unity. 搜索统一内的自定义编辑器

You can save designer's data into a ScriptableObject and use it later in runtime. 您可以将设计者的数据保存到ScriptableObject中,并在以后的运行时中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM