SCameraManager
客户端场景
成员 10
| 属性 | IsLocked | Is the Camera locked? |
| 属性 | MainCamera | Note, this property is generally read-only. |
| 属性 | ActiveVirtualCamera | The currently active Cinemachine Virtual Camera game object. |
| 函数 | LockCamera | Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called. |
| 函数 | ReleaseCamera | Calling this function reverses the LockCamera() call and returns control of the Camera to the viewer. |
| 函数 | SetCameraPositionOrientation | Sets the Camera's position and rotation. |
| 函数 | ScreenCoordinatesToRay | Returns a ray going from camera through a screen point. |
| 函数 | ScreenCoordinatesToWorld | Transforms a point from screen space into world space. |
| 函数 | WorldCoordinatesToScreen | – |
| 函数 | ShakeCamera | – |
属性
IsLocked只读
bool IsLocked {get; }
Is the Camera locked?
示例
Lua
isCameraLocked = Space.Camera.IsLocked
MainCamera只读
Note, this property is generally read-only. It's position is driven by internal code.
示例
Lua
mainCamera = Space.Camera.MainCamera
ActiveVirtualCamera只读
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
Sets the Camera's position and rotation. This function requires the camera to be locked.
参数
| 参数 | 类型 | 说明 |
|---|---|---|
| position | SVector | The World Postion of the camera GameObject. |
| orientation | SQuaternion | The World Rotation of the camera GameObject. |
返回值
void
示例
Lua
Space.Camera.SetCameraPositionOrientation (Vector.New(0,0,0),Quaternion.Euler(-60,0,0));
ScreenCoordinatesToRay
Returns a ray going from camera through a screen point.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| screenCoordinates | SVector | – |
返回值
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
Transforms a point from screen space into world space.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| screenCoordinates | SVector | – |
返回值
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
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| coordinates | SVector | – |
返回值
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)
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| magnitude | float | – |
| time | float | – |
| amplitude | float | – |
| frequency | float | – |
返回值
void
示例
Lua
Space.Camera.ShakeCamera(1, 1.0)
--or
Space.Camera.ShakeCamera(2, 1, 1.0)



