Class TDCameraController

Namespace
TDMaker.Unity.View
Assembly
TDMaker.Unity.dll

Orthographic 2D camera for a level: frames the level on start using the level's CameraFramingData (fit the whole map, fit its height or width and scroll, or a fixed view size; start focus and optional intro pan) at any aspect ratio, and optionally pans (screen edge, middle-mouse drag, WASD/arrows, left drag from empty ground) and zooms (mouse wheel, +/-), always clamped to the bounds. Toggles live in TDGameSettings.

[RequireComponent(typeof(Camera))]
[DefaultExecutionOrder(90)]
[AddComponentMenu("2D Tower Defense Maker/Camera Controller")]
public sealed class TDCameraController : MonoBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
TDCameraController
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Constructors

TDCameraController()

public TDCameraController()

Properties

Bounds

The bounds the camera is clamped to (level geometry plus padding).

public Rect Bounds { get; }

Property Value

Rect

Framing

The framing in use (from the baked level; default Fit Whole Map).

public CameraFramingData Framing { get; }

Property Value

CameraFramingData

IntroPanActive

Whether the intro pan is running.

public bool IntroPanActive { get; }

Property Value

bool

LeftDragging

Whether a left-button drag is panning the camera (GameHud ignores the release of such a press as a click).

public bool LeftDragging { get; }

Property Value

bool

Methods

Configure(SimulationRunner)

Assigns the runner; call before enabling.

public void Configure(SimulationRunner source)

Parameters

source SimulationRunner

FitToLevel()

Fits the whole level into view and resets zoom. Safe to call in edit mode.

public void FitToLevel()

FocusPoint(LevelDef, Rect, CameraStartFocus)

World point the view starts on: the bounds' centre, or the first path's entrance or exit.

public static Vector2 FocusPoint(LevelDef level, Rect area, CameraStartFocus startFocus)

Parameters

level LevelDef
area Rect
startFocus CameraStartFocus

Returns

Vector2

SetFixedBounds(Rect?)

Clamps the camera to a fixed world rectangle (for example the painted map of the level) instead of the level geometry. Pass null to fit the level geometry again. Applies on the next start.

public void SetFixedBounds(Rect? area)

Parameters

area Rect?

VisibleRect()

Visible world rectangle (axis-aligned).

public Rect VisibleRect()

Returns

Rect