# SCameraManager

**الأعضاء** 10

|       |                                                               |                                                                                                                                          |
| ----- | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| خاصية | [IsLocked](#islocked)                                         | Is the Camera locked?                                                                                                                    |
| خاصية | [MainCamera](#maincamera)                                     | Note, this property is generally read-only.                                                                                              |
| خاصية | [ActiveVirtualCamera](#activevirtualcamera)                   | The currently active Cinemachine Virtual Camera game object.                                                                             |
| دالة  | [LockCamera](#lockcamera)                                     | Calling this function stops the Camera from being controlled by the viewer, and allows us to control it until ReleaseCamera() is called. |
| دالة  | [ReleaseCamera](#releasecamera)                               | Calling this function reverses the LockCamera() call and returns control of the Camera to the viewer.                                    |
| دالة  | [SetCameraPositionOrientation](#setcamerapositionorientation) | Sets the Camera's position and rotation.                                                                                                 |
| دالة  | [ScreenCoordinatesToRay](#screencoordinatestoray)             | Returns a ray going from camera through a screen point.                                                                                  |
| دالة  | [ScreenCoordinatesToWorld](#screencoordinatestoworld)         | Transforms a point from screen space into world space.                                                                                   |
| دالة  | [WorldCoordinatesToScreen](#worldcoordinatestoscreen)         | –                                                                                                                                        |
| دالة  | [ShakeCamera](#shakecamera)                                   | –                                                                                                                                        |

## الخصائص

### IsLocked

bool IsLocked {get; }

Is the Camera locked?

مثال

**Lua**

```lua
isCameraLocked = Space.Camera.IsLocked

```

### MainCamera

[SGameObject](/docs/ar/scripting/client-scripting-api-reference/types/sgameobject.md) MainCamera {get; }

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

مثال

**Lua**

```lua
mainCamera = Space.Camera.MainCamera

```

### ActiveVirtualCamera

[SGameObject](/docs/ar/scripting/client-scripting-api-reference/types/sgameobject.md) ActiveVirtualCamera {get; }

The currently active Cinemachine Virtual Camera game object.

مثال

**Lua**

```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()*](/docs/ar/scripting/client-scripting-api-reference/region/scameramanager.md#releasecamera) is called.

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

`void`

مثال

**Lua**

```lua
Space.Camera.LockCamera()

```

### ReleaseCamera

void ReleaseCamera()

Calling this function reverses the [*LockCamera()*](/docs/ar/scripting/client-scripting-api-reference/region/scameramanager.md#lockcamera) call and returns control of the Camera to the viewer.

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

`void`

مثال

**Lua**

```lua
Space.Camera.ReleaseCamera()

```

### SetCameraPositionOrientation

void SetCameraPositionOrientation([SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) position, [SQuaternion](/docs/ar/scripting/client-scripting-api-reference/types/squaternion.md) orientation)

Sets the Camera's position and rotation. This function requires [*t*he camera to be locked.](/docs/ar/scripting/client-scripting-api-reference/region/scameramanager.md#lockcamera)

المعاملات

| المعامل     | النوع                                                                                 | الوصف                                        |
| ----------- | ------------------------------------------------------------------------------------- | -------------------------------------------- |
| position    | [SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md)         | The World Postion of the camera GameObject.  |
| orientation | [SQuaternion](/docs/ar/scripting/client-scripting-api-reference/types/squaternion.md) | The World Rotation of the camera GameObject. |

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

`void`

مثال

**Lua**

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

```

### ScreenCoordinatesToRay

[SRay ](/docs/ar/scripting/client-scripting-api-reference/types/sray.md)ScreenCoordinatesToRay([SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) screenCoordinates)

Returns a ray going from camera through a screen point.

المعاملات

| الاسم             | النوع                                                                         | القيمة الافتراضية |
| ----------------- | ----------------------------------------------------------------------------- | ----------------- |
| screenCoordinates | [SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) | –                 |

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

`SRay`

مثال

**Lua**

```lua
cameraRay = Space.Camera.ScreenCoordinatesToRay (Vector.New(0,50,0))

```

**Lua**

```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 ](/docs/ar/scripting/client-scripting-api-reference/types/svector.md)ScreenCoordinatesToWorld([SVector ](/docs/ar/scripting/client-scripting-api-reference/types/svector.md)screenCoordinates)

Transforms a point from screen space into world space.

المعاملات

| الاسم             | النوع                                                                         | القيمة الافتراضية |
| ----------------- | ----------------------------------------------------------------------------- | ----------------- |
| screenCoordinates | [SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) | –                 |

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

`SVector`

مثال

**Lua**

```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](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) WorldCoordinatesToScreen([SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) coordinates)

المعاملات

| الاسم       | النوع                                                                         | القيمة الافتراضية |
| ----------- | ----------------------------------------------------------------------------- | ----------------- |
| coordinates | [SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) | –                 |

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

`SVector`

مثال

**Lua**

```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**

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

```
