Class ExtensionMethods
Provides extension methods for calculating and manipulating bounds in Unity, as well as fitting a camera view to those bounds.
Inherited Members
Namespace: FBXImporter
Assembly: FBXImporter.dll
Syntax
public static class ExtensionMethods
Methods
CalculateBounds(GameObject, bool)
Calculates the bounding volume of this UnityEngine.GameObject using its child UnityEngine.Renderer components. You can optionally calculate the bounds in local space by temporarily resetting the transform.
Declaration
public static Bounds CalculateBounds(this GameObject gameObject, bool localSpace = false)
Parameters
Type | Name | Description |
---|---|---|
GameObject | gameObject | The UnityEngine.GameObject for which to calculate the bounds. |
bool | localSpace | Pass |
Returns
Type | Description |
---|---|
Bounds | The calculated UnityEngine.Bounds. |
CalculatePreciseBounds(GameObject)
Calculates a precise bounding volume for this UnityEngine.GameObject by examining the actual mesh data of UnityEngine.MeshFilter and UnityEngine.SkinnedMeshRenderer components.
Declaration
public static Bounds CalculatePreciseBounds(this GameObject gameObject)
Parameters
Type | Name | Description |
---|---|---|
GameObject | gameObject | The UnityEngine.GameObject to calculate precise bounds for. |
Returns
Type | Description |
---|---|
Bounds | The calculated UnityEngine.Bounds encompassing all mesh data. |
FitToBounds(Camera, Bounds, float)
Positions the camera so that the specified UnityEngine.Bounds fit within its view at the given distance factor.
Declaration
public static void FitToBounds(this Camera camera, Bounds bounds, float distance)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera that will be repositioned. |
Bounds | bounds | The UnityEngine.Bounds to fit into the camera's view. |
float | distance | A multiplier determining how far the camera will be placed relative to the bounding volume. Higher values place the camera farther away. |
FitToBounds(Camera, GameObject, float)
Positions the camera so that this UnityEngine.GameObject's bounds fit within its view at the given distance factor.
Declaration
public static void FitToBounds(this Camera camera, GameObject gameObject, float distance)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera that will be repositioned. |
GameObject | gameObject | The UnityEngine.GameObject whose bounds should fit in the view. |
float | distance | A multiplier determining how far the camera will be placed relative to the bounding volume. Higher values place the camera farther away. |
FrameBounds(Camera, Bounds, float)
Frames the specified UnityEngine.Camera around a given UnityEngine.Bounds at a specified distance multiplier. This effectively centers the camera on the bounds.
Declaration
public static void FrameBounds(this Camera camera, Bounds bounds, float distance)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera to adjust to frame the bounds. |
Bounds | bounds | The bounding volume to focus on. |
float | distance | A multiplier for how far away the camera should be from the bounds center. Higher values place the camera farther away. |