Unity Learning Note: creation and use of precast parts prefab

Source: Internet
Author: User

In the process of making a game, you will need to create multiple identical gameobject by code, such as bullets in shooting games, miscellaneous soldiers and many others.

Commonly called prefab prefabrication in Unity, it acts as a template and can replicate the same gameobject quickly.

Creating Prefab Precast Parts

In general, separate catalogs are created to store prefabricated parts.

The first of these methods

Add a gameobject to the scene to complete the relevant settings. and drag it into the assets/prefabs.

The second method of

In Assets/prefabs, new empty precast parts

Then drag the gameobject in the scene to the top

Prefab precast parts are synchronized with their generated objects

The gameobject in the figure has three options:

Select positioning precast parts;

Revert Reset the Current property = The properties of the prefab;

Apply saves the current property and updates it to the prefab properties.

Created in code

Created using the instantiate method. For example:

Gameobject OGame = Instantiate (_prefab);

Unity Learning Note: creation and use of precast parts prefab

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.