GridBrushBase

class in UnityEngine

/

Hereda de:ScriptableObject

Cambiar al Manual

Descripción

Base class for authoring data on a grid with grid painting tools like paint, erase, pick, select and fill.

Inheriting this class and/or creating brush asset instances from your inherited class, you can create custom brushes which react to high level grid events like paint, erase, pick, select and fill.

using UnityEngine;

// Paints two prefabs in checkerboard pattern [CreateAssetMenu] public class CheckerboardBrush : GridBrushBase { public GameObject prefabA; public GameObject prefabB;

public override void Paint(GridLayout grid, GameObject brushTarget, Vector3Int position) { bool evenCell = Mathf.Abs(position.y + position.x) % 2 > 0; GameObject toBeInstantiated = evenCell ? prefabA : prefabB;

if (toBeInstantiated != null) { GameObject newInstance = Instantiate(toBeInstantiated, grid.CellToWorld(position), Quaternion.identity); newInstance.transform.SetParent(brushTarget.transform); } } }

Funciones Públicas

BoxEraseErases data on a grid within the given bounds.
BoxFillBox fills tiles and GameObjects into given bounds within the selected layers.
EraseErases data on a grid within the given bounds.
FlipFlips the grid brush in the given FlipAxis.
FloodFillFlood fills data onto a grid given the starting coordinates of the cell.
MoveMove is called when user moves the area previously selected with the selection marquee.
MoveEndMoveEnd is called when user has ended the move of the area previously selected with the selection marquee.
MoveStartMoveEnd is called when user starts moving the area previously selected with the selection marquee.
PaintPaints data into a grid within the given bounds.
PickPicks data from a grid given the coordinates of the cells.
RotateRotates all tiles on the grid brush with the given RotationDirection.
SelectSelect an area of a grid.

Miembros heredados

Variables

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameEl nombre del objeto.

Funciones Públicas

GetInstanceIDDevuelve el id de la instancia del objeto.
ToStringReturns the name of the GameObject.

Funciones Estáticas

DestroyElimina un gameobject, componente o asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeDevuelve el primer objeto activo cargado de tipo type.
FindObjectsOfTypeDevuelve una lista de todos los objetos activos cargados de tipo type.
InstantiateClona el objeto original y devuelve el clon.
CreateInstanceCrea una instancia de un objeto scriptable.

Operadores

bool¿Existe el objeto?
operator !=Compare si dos objetos se refieren a un objeto diferente.
operator ==Compara dos referencias de objeto para ver si se refieren al mismo objeto.

Mensajes

AwakeEsta función se llama cuando el script ScriptableObject empieza.
OnDestroyEsta función se llama cuando el objeto scriptable se destruirá.
OnDisableEsta función se llama cuando el objeto scriptable se va fuera del alcance (scope).
OnEnableEsta función se llama cuando el objeto es cargado.