SCameraManager
Dans cette classeIsLocked
| Propriété | IsLocked | Is the Camera locked? |
| Propriété | MainCamera | Note, this property is generally read-only. |
| Propriété | ActiveVirtualCamera | The currently active Cinemachine Virtual Camera game object. |
| Fonction | LockCamera | Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called. |
| Fonction | ReleaseCamera | Calling this function reverses the LockCamera() call and returns control of the Camera to the viewer. |
| Fonction | SetCameraPositionOrientation | Sets the Camera's position and rotation. |
| Fonction | ScreenCoordinatesToRay | Returns a ray going from camera through a screen point. |
| Fonction | ScreenCoordinatesToWorld | Transforms a point from screen space into world space. |
| Fonction | WorldCoordinatesToScreen | – |
| Fonction | ShakeCamera | – |
Propriétés
IsLockedLecture seule
Is the Camera locked?
Exemple
isCameraLocked = Space.Camera.IsLocked
MainCameraLecture seule
Note, this property is generally read-only. It's position is driven by internal code.
Exemple
mainCamera = Space.Camera.MainCamera
ActiveVirtualCameraLecture seule
The currently active Cinemachine Virtual Camera game object.
Exemple
currentCamera = Space.Camera.ActiveVirtualCamera
Fonctions
LockCamera
Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called.
Valeurs de retour
void
Exemple
Space.Camera.LockCamera()
ReleaseCamera
Calling this function reverses the LockCamera() call and returns control of the Camera to the viewer.
Valeurs de retour
void
Exemple
Space.Camera.ReleaseCamera()
SetCameraPositionOrientation
Sets the Camera's position and rotation. This function requires the camera to be locked.
Paramètres
| Paramètre | Type | Description |
|---|---|---|
| position | SVector | The World Postion of the camera GameObject. |
| orientation | SQuaternion | The World Rotation of the camera GameObject. |
Valeurs de retour
void
Exemple
Space.Camera.SetCameraPositionOrientation (Vector.New(0,0,0),Quaternion.Euler(-60,0,0));
ScreenCoordinatesToRay
Returns a ray going from camera through a screen point.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| screenCoordinates | SVector | – |
Valeurs de retour
SRay
Exemple
cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,50,0))
--this script will make this object jump to wherever you right click
--(Example: moving objects with right click )
thisGameObject = Space.Host.ExecutingObject
OnUpdate = function()
if Space.Input.GetMouseDown(1) then
clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition)
rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0)
thisGameObject.WorldPosition = rayCastHit.Position
end
end
thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate)
ScreenCoordinatesToWorld
Transforms a point from screen space into world space.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| screenCoordinates | SVector | – |
Valeurs de retour
SVector
Exemple
obj = Space.Host.ExecutingObject;
Space.Log(Space.Camera.ScreenCoordinatesToWorld(Vector.New(0.5,0.5,0)).ToString());
-- Print 3 worldspace vectors created by screen space point to the console.
WorldCoordinatesToScreen
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| coordinates | SVector | – |
Valeurs de retour
SVector
Exemple
local trans = Space.Host.ExecutingObject;
Space.Log(Space.Camera.WorldCoordinatesToScreen(trans.WorldPosition).ToString());
-- Print the position created by world space point to the console.
ShakeCamera
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| magnitude | float | – |
| time | float | – |
| amplitude | float | – |
| frequency | float | – |
Valeurs de retour
void
Exemple
Space.Camera.ShakeCamera(1, 1.0)
--or
Space.Camera.ShakeCamera(2, 1, 1.0)



