如何以一种可以调整一个游戏对象的克隆属性以匹配场景视图中的所有其他游戏对象的方式克隆多个游戏对象 [英] how to clone several game objects in a way that clone properties of one can be adjusted to match all others in scene view

查看:25
本文介绍了如何以一种可以调整一个游戏对象的克隆属性以匹配场景视图中的所有其他游戏对象的方式克隆多个游戏对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问了 如何调整一个克隆的形状/尺寸以影响场景视图中的所有其他克隆 并且接受的答案是正确的.它只能克隆一个游戏对象.我尝试进行一些调整,但我想出的唯一解决方案是为其他对象添加重复的方法.这在处理多个要克隆的游戏对象时效果不佳.

I asked How can I adjust shape/dimensions of one clone to affect all other clones in the scene view and the accepted answer was spot on. It could only clone one game object. I tried making some adjustments but the only solution I came up with was adding duplicate methods for additional objects. This doesn't work well when dealing with several game objects to be cloned.

如何克隆多个独特的游戏对象,以便调整一个克隆的组件/属性会影响场景视图中该对象的所有其他克隆?

How can I clone several unique game objects so that adjusting the components/properties of one clone would affect all other clones of that object in the scene view?

请注意,我不想在运行时实现这一点,也不想使用预制件.我使用它来帮助创建复杂的关卡,因此正在调整的克隆的实时更新非常重要.

Please note that I don't want to achieve this at runtime and I don’t want to use prefabs. I am using this to help with creation of complex levels so the live update of clones being adjusted is very important.

此外,我还需要一种方法来关闭每个克隆上的这种重复的属性/组件复制,最好是用一个按钮.

Additionally, I also need a way to turn off the this repeated property/component replication on each clone, preferably with a button.

推荐答案

我不想使用预制件

I don’t want to use prefabs

Unity 中的新预制系统正是您所需要的.它符合您的所有要求:

The new prefab system in Unity is exactly what you need. It fits all of your requirements:

  • 克隆几个独特的游戏对象

预制系统用于克隆独特的游戏对象.它甚至支持预制嵌套.

The prefab system is made for cloning unique gameobjects. It even supports prefab nesting.

我不想在运行时实现这个

太好了,预制件只会在您单击编辑器中的覆盖按钮时全局更新.

Great, prefabs only update globally when you click the override button in the editor.

我需要一种方法来关闭每个克隆上重复的属性/组件复制

这相当于解包对象(断开连接).

That's equivalent to unpacking the object (breaking the connection).

如果您有充分的理由避免使用预制件,您始终可以编写一个自定义脚本来跟踪您要共享的属性的变化,并立即更新所有其他对象.您可以通过将 [ExecuteInEditMode] 属性添加到它所在的类来使该脚本在编辑模式下运行,只是在运行项目时不要忘记禁用它.同样,我强烈建议改用预制件.

If you have a good reason to avoid using prefabs, you can always write a custom script that tracks changes in the properties you want to share, and updates all other objects immediately. You can make that script run in edit mode by adding the [ExecuteInEditMode] attribute to the class it's in, just don't forget to disable it when running the project. Again, I highly recommend using prefabs instead.

这篇关于如何以一种可以调整一个游戏对象的克隆属性以匹配场景视图中的所有其他游戏对象的方式克隆多个游戏对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆