prefabs

Once you've dragged a mesh into the scene, assigned a material and texture, scripts, sounds, physics properties, etc., you don't want to have to repeat the process to create identical or nearly identical game objects. You can use the Duplicate command to take care of that. For example, if you create the wheel of a car, you can Duplicate it three times and move the copies to the appropriate positions.

But what if you want to make a change that applies to all of them? It'll be a pain to make the same change four times. And what it you want to reuse the object in another scene, or even another project? Prefabs are your answer.

Prefabs are what they sound like - prefrabicated game objects, and like other assets, you drag them from the Project window into your scene Hierarchy, and the result is a new game object patterned after the prefab. Once in the Hierarchy, you can modify the game object. For example, you'll almost certainly want to adjust the position. Selecting Apply Changes to Prefab will store any changes in the prefab and any other instance of the prefab will inherit those changes (except for those properties that have been overridden).

If you make a significant enough change, e.g. adding or removing a child, the Editor will warn you that you're going to break the object's connection with its prefab, meaning any changes to the prefab won't show up in this game object, anymore. Apply Changes will bring it back into the fold but of course change the prefab, too.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值