Breakroom is now Sinewave Campus. Book a meeting

SCameraManager

العميلالمشهد
في هذا الصنفIsLocked
  1. الخصائص
  2. IsLocked
  3. MainCamera
  4. ActiveVirtualCamera
  5. الدوال
  6. LockCamera
  7. ReleaseCamera
  8. SetCameraPositionOrientation
  9. ScreenCoordinatesToRay
  10. ScreenCoordinatesToWorld
  11. WorldCoordinatesToScreen
  12. ShakeCamera
الأعضاء 10
خاصيةIsLockedIs the Camera locked?
خاصيةMainCameraNote, this property is generally read-only.
خاصيةActiveVirtualCameraThe currently active Cinemachine Virtual Camera game object.
دالةLockCameraCalling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called.
دالةReleaseCameraCalling this function reverses the LockCamera() call and returns control of the Camera to the viewer.
دالةSetCameraPositionOrientationSets the Camera's position and rotation.
دالةScreenCoordinatesToRayReturns a ray going from camera through a screen point.
دالةScreenCoordinatesToWorldTransforms a point from screen space into world space.
دالةWorldCoordinatesToScreen–
دالةShakeCamera–

الخصائص​

IsLockedللقراءة فقط​

bool IsLocked {get; }

Is the Camera locked?

مثال

Lua
isCameraLocked = Space.Camera.IsLocked

MainCameraللقراءة فقط​

SGameObject MainCamera {get; }

Note, this property is generally read-only. It's position is driven by internal code.

مثال

Lua
mainCamera = Space.Camera.MainCamera

ActiveVirtualCameraللقراءة فقط​

SGameObject ActiveVirtualCamera {get; }

The currently active Cinemachine Virtual Camera game object.

مثال

Lua
currentCamera = Space.Camera.ActiveVirtualCamera

الدوال​

LockCamera​

void LockCamera()

Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called.

القيم المرجعة

void

مثال

Lua
Space.Camera.LockCamera()

ReleaseCamera​

void ReleaseCamera()

Calling this function reverses the LockCamera() call and returns control of the Camera to the viewer.

القيم المرجعة

void

مثال

Lua
Space.Camera.ReleaseCamera()

SetCameraPositionOrientation​

void SetCameraPositionOrientation(SVector position, SQuaternion orientation)

Sets the Camera's position and rotation. This function requires the camera to be locked.

المعاملات

المعاملالنوعالوصف
positionSVectorThe World Postion of the camera GameObject.
orientationSQuaternionThe World Rotation of the camera GameObject.

القيم المرجعة

void

مثال

Lua
Space.Camera.SetCameraPositionOrientation (Vector.New(0,0,0),Quaternion.Euler(-60,0,0));

ScreenCoordinatesToRay​

SRay ScreenCoordinatesToRay(SVector screenCoordinates)

Returns a ray going from camera through a screen point.

المعاملات

الاسمالنوعالقيمة الافتراضية
screenCoordinatesSVector–

القيم المرجعة

SRay

مثال

Lua
cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,50,0))
Lua
--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​

SVector ScreenCoordinatesToWorld(SVector screenCoordinates)

Transforms a point from screen space into world space.

المعاملات

الاسمالنوعالقيمة الافتراضية
screenCoordinatesSVector –

القيم المرجعة

SVector

مثال

Lua
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​

SVector WorldCoordinatesToScreen(SVector coordinates)

المعاملات

الاسمالنوعالقيمة الافتراضية
coordinatesSVector–

القيم المرجعة

SVector

مثال

Lua
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​

void ShakeCamera(float magnitude, float time)
void ShakeCamera(float amplitude, float frequency, float time)

المعاملات

الاسمالنوعالقيمة الافتراضية
magnitudefloat–
timefloat–
amplitudefloat–
frequencyfloat–

القيم المرجعة

void

مثال

Lua
Space.Camera.ShakeCamera(1, 1.0)
--or
Space.Camera.ShakeCamera(2, 1, 1.0)