官术网_书友最值得收藏!

Prefabs

Imagine that you have been hired to build a holographic corporate team-building exercise for an upcoming weekend event. The idea is to create a scavenger hunt to find a cute robot and you have a large group of mean robots trying to stop everyone. The event is a gamified first-person shooter/scavenger hunt. The winning team will get the real robot to help in their office. It will be fun; let the team get some tension out and repair some troubled relationships in the company. From the word go, you will be using prefabs. 

A prefab is a Unity asset type that acts as a blueprint or a template. In our preceding example, something as simple as the bullets for the weapons or as complex as the large collection of really mean robots that are trying to stop the entire company from achieving their goals could also be prefabs.

Fundamentally, a prefab is a hierarchical collection of GameObjects and their associated components. Using a parent/child relationship very similar to the file folder system of a computer. A developer can create a complex object made out of many objects, and then copy that object in memory. This is a process known as instantiation, but can easily be understood as cloning.

The benefit of this process is when you need to create 15 robots for a robot game, at any given time you will get more efficient use of memory. Without instantiation and prefabs, each of those robots will take up their own space in memory and potentially start to bog the system down. With this cloning process, these objects that acquire space of memory and therefore use far less memory. 

主站蜘蛛池模板: 阿拉尔市| 固镇县| 离岛区| 锦州市| 汉沽区| 青川县| 元氏县| 吴忠市| 道孚县| 隆安县| 张家口市| 溆浦县| 印江| 涿州市| 神池县| 汪清县| 山丹县| 临夏市| 木里| 阿克陶县| 高平市| 门头沟区| 五常市| 综艺| 化隆| 莲花县| 剑川县| 晋江市| 勃利县| 韩城市| 巴中市| 桐柏县| 四子王旗| 来宾市| 清涧县| 无极县| 定西市| 勐海县| 灵台县| 奇台县| 宜兰市|