π¦₯Placement Bounds
Check out how placement bounds function and how to implement your own!
Overview
For defining object's placement bounds interface IPlacementBounds is used, it must define bounds and rotation the object and its reference to gameObject itself.
Interface
/// <summary>
/// Interface for providing placement bounds for a placing object.
/// </summary>
public interface IPlacementBounds
{
/// <summary>
/// Root game object of the placing object.
/// </summary>
public GameObject gameObject { get; }
/// <summary>
/// Bounds relative to local position of the root "gameObject".
/// </summary>
public Bounds PlacementBounds { get; }
/// <summary>
/// Absolute rotation of the placing object.
/// </summary>
public Quaternion PlacementRotation { get; }
}Provided components which implement this interface:
APlacementBounds: abstract class for implementing custom behaviour
CustomPlacementBounds: defines bounds by
center&sizepropertiesRendererPlacementBounds: supports referencing a specific renderer from which bounds are retrieved
ColliderPlacementBounds: supports referencing a specific collider from which bounds are calculated
IPlacementBounds or APlacementBounds can be used to implement your own behaviour for placement bounds
Best Practices
It is recommended that these bounds are defined in Editor and not at runtime. However it is still possible to do it in code.
Example 1:
Example 2:
Last updated