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

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

问题描述

我问

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:

  • Clone several unique game objects

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

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

I don't want to achieve this at runtime

很棒,当您在编辑器中单击覆盖按钮时,预制件才会全局更新.

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

I need a way to turn off the this repeated property/component replication on each clone

那相当于解压缩对象(断开连接).

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天全站免登陆