Loading...
Searching...
No Matches
CityBuilderCore.CameraController Class Reference

Detailed Description

camera controller that works with various setups and provides mouse inpurt and main camera interfaces

https://citybuilder.softleitner.com/manual

Inheritance diagram for CityBuilderCore.CameraController:
CityBuilderCore.IMouseInput CityBuilderCore.IMainCamera

Public Member Functions

Ray GetRay (bool applyOffset=false)
 creates a ray under the players mouse that points in the cameras direction
can be used to check whats currently under the player pointer
 
Vector3 GetMousePosition (bool applyOffset=false)
 calculates absolute world position on the map that the pointer is currently over
 
Vector2 GetMouseScreenPosition (bool applyOffset=false)
 calculates the current position of the players pointer in screen coordinates
 
Vector2Int GetMouseGridPosition (bool applyOffset=false)
 calculates the point on the map that the pointer is currently over
 
void SetCulling (LayerMask layerMask)
 sets the culling of the main camera to the passed mask
the original mask is saved so it can be restored using ResetCulling
 
void ResetCulling ()
 resets the culling on the main camera to its original layer mask after is has been changed by SetCulling(LayerMask)
 
CoroutineToken Jump (Vector3 position, Quaternion? rotation=null)
 quickly moves the camera to a position on the map
for example to focus on some happening
 
CoroutineToken Follow (Transform leader)
 moves the camera to a transform and follows it
following is canceled when the user moves the camera or the transform becomes inactive
 
Ray GetRay (Vector2 screenPosition)
 
Vector3 GetMousePosition (Vector2 screenPosition)
 

Public Attributes

Camera Camera
 
Transform Pivot
 
float Speed = 5
 
float RotateSpeed = 50
 
float PitchSpeed = 50
 
float ZoomSpeed = 10
 
float MinZoom = 2
 
float MaxZoom = 15
 
Vector3 SortAxis
 
Collider MouseCollider
 
Collider ZoomCollider
 
float ZoomColliderDistance = 1f
 
bool TwoFingerPan = true
 
float PinchSpeed = 0.005f
 
Vector2 TouchOffset = Vector3.zero
 

Protected Member Functions

virtual void Awake ()
 
virtual void Start ()
 

Properties

Vector3 Position [get, set]
 position the camera point to on the map, not the position of the camera itself
 
Quaternion Rotation [get, set]
 current rotation of the main camera(used only to persist camera rotation currently), only applies in 3d
 
float Size [get, set]
 current size of the main camera(used only to persist camera size currently)
 
- Properties inherited from CityBuilderCore.IMainCamera

Member Function Documentation

◆ Follow()

CoroutineToken CityBuilderCore.CameraController.Follow ( Transform leader)
inline

moves the camera to a transform and follows it
following is canceled when the user moves the camera or the transform becomes inactive

Parameters
leaderthe transform the camera should follow

Implements CityBuilderCore.IMainCamera.

◆ GetMouseGridPosition()

Vector2Int CityBuilderCore.CameraController.GetMouseGridPosition ( bool applyOffset = false)

calculates the point on the map that the pointer is currently over

Parameters
applyOffsetwhether the touch offset should be applied
Returns
a grid point on the map

Implements CityBuilderCore.IMouseInput.

◆ GetMousePosition()

Vector3 CityBuilderCore.CameraController.GetMousePosition ( bool applyOffset = false)
inline

calculates absolute world position on the map that the pointer is currently over

Parameters
applyOffsetwhether the touch offset should be applied
Returns
a position on the map

Implements CityBuilderCore.IMouseInput.

◆ GetMouseScreenPosition()

Vector2 CityBuilderCore.CameraController.GetMouseScreenPosition ( bool applyOffset = false)
inline

calculates the current position of the players pointer in screen coordinates

Parameters
applyOffsetwhether the touch offset should be applied
Returns
screen space position of the pointer

Implements CityBuilderCore.IMouseInput.

◆ GetRay()

Ray CityBuilderCore.CameraController.GetRay ( bool applyOffset = false)

creates a ray under the players mouse that points in the cameras direction
can be used to check whats currently under the player pointer

Parameters
applyOffsetwhether the touch offset should be applied
Returns
a ray coming from the pointer

Implements CityBuilderCore.IMouseInput.

◆ Jump()

CoroutineToken CityBuilderCore.CameraController.Jump ( Vector3 position,
Quaternion? rotation = null )
inline

quickly moves the camera to a position on the map
for example to focus on some happening

Parameters
positionthe absolute position on the map
rotationoptional rotation the camera should have

Implements CityBuilderCore.IMainCamera.

◆ ResetCulling()

void CityBuilderCore.CameraController.ResetCulling ( )

resets the culling on the main camera to its original layer mask after is has been changed by SetCulling(LayerMask)

Implements CityBuilderCore.IMainCamera.

◆ SetCulling()

void CityBuilderCore.CameraController.SetCulling ( LayerMask layerMask)

sets the culling of the main camera to the passed mask
the original mask is saved so it can be restored using ResetCulling

Parameters
layerMaskthe layer mask to set on the main camera

Implements CityBuilderCore.IMainCamera.

Property Documentation

◆ Position

Vector3 CityBuilderCore.CameraController.Position
getset

position the camera point to on the map, not the position of the camera itself

Implements CityBuilderCore.IMainCamera.

◆ Rotation

Quaternion CityBuilderCore.CameraController.Rotation
getset

current rotation of the main camera(used only to persist camera rotation currently), only applies in 3d

Implements CityBuilderCore.IMainCamera.

◆ Size

float CityBuilderCore.CameraController.Size
getset

current size of the main camera(used only to persist camera size currently)

Implements CityBuilderCore.IMainCamera.