简体   繁体   English

Unity可以在层次结构中添加游戏对象,但不能实例化它吗?

[英]Unity is possible to add a Game Object in hierarchy but not instantiate it?

I'm not sure if it is possible to create a Game Object in the scene (so it appears in the hierarchy) but I would like Unity to not instantiate (or rather remove it) such Game Object when I press play. 我不确定是否可以在场景中创建游戏对象(因此它会出现在层次结构中),但是我希望Unity在我按下play时不实例化(或删除它)这样的游戏对象。

The reason why I want to do that. 我想这样做的原因。 I'm creating Game Objects as 'enemy spawners' in my game. 我在游戏中将游戏对象创建为“敌人生成器”。 But I don't want to have those transforms or Game Objects actually in memory while the game is running. 但我不想在游戏运行时将这些转换或游戏对象实际存储在内存中。 So I've created an editor script that search for all the spawner entities, retrieve the information that I need and creates a binary file with it that later the enemy manager reads in run time during the initialization process. 因此,我创建了一个编辑器脚本,该脚本可搜索所有产生者实体,检索我需要的信息,并使用该脚本创建一个二进制文件,稍后敌人管理器会在初始化过程中在运行时读取该文件。

If this is not possible, do you guys have any recommendations on how I could implement something similar? 如果这不可能,你们对我如何实现类似的东西有什么建议吗?

Many thanks in advance. 提前谢谢了。

You are looking for scriptable objects. 您正在寻找可编写脚本的对象。

Here are some URL's 这是一些URL

ScriptableObject Tutorial from Unity Unity的ScriptableObject教程

ScriptableObject documentation ScriptableObject文档

ScriptableObjects can be accesed at any time and don't have to be instantiated before you can use them. ScriptableObjects可以随时访问,无需实例化即可使用。 So they won't have a transform. 因此,他们将不会进行转换。

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

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