docs.unity3d.com
    Show / Hide Table of Contents

    Prefab Brush

    Contributions by: Pepperized, superkerokero, vladderb, RyotaMurohoshi, ManickYoj, Quickz

    This Brush instances and places randomly selected Prefabs onto the target location and parents the instanced object to the paint target. Use this Brush as an example to create custom Brushes which can quickly place an assortment of GameObjects onto structured locations.

    Properties

    Property Function
    Perlin Scale The factor using the Perlin noise algorithm for the random distribution of Prefabs chosen when painting.
    Prefabs Set the number of and selection of Prefabs to paint from.
    Size Set the number of Prefabs that the Brush selects from.
    Element * Set one of the Prefabs to select from for each entry. The number of Element entries matches the value set in Size.

    Usage

    First set the number of Prefabs to select from in the Prefabs property, then add Prefab Assets to the list. Adjust the Perlin Scale property to adjust the distribution of Prefabs painted onto a particular cell.

    Brush Editor with Prefab Brush

    When painting with the Prefab Brush, the Prefab Brush picks from the available Prefabs based on the Perlin Scale set, and instantiate the Prefabs to the Scene.

    Scene View with Prefab Brush

    Implementation

    The Prefab Brush inherits from the Grid Brush and implements the following overrides:

    • It overrides the Paint method to paint a Prefab from the Prefab selection.
    • It overrides the Erase method to be able to erase the instantiated Prefabs or other GameObjects from the Scene.
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023