Browse Source

camera manager updated

main
cailean 10 months ago
parent
commit
c4f27f40be
  1. 8
      Assets/6_Scenes/Beep.unity
  2. 42
      Assets/7_Scripts/Camera/CameraManager.cs
  3. 0
      Assets/7_Scripts/Camera/CameraSwitchScript.cs
  4. 0
      Assets/7_Scripts/Camera/CameraSwitchScript.cs.meta
  5. 2
      Assets/ML-Agents/Timers/Beep_timers.json

8
Assets/6_Scenes/Beep.unity

@ -1345,7 +1345,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 470663197}
serializedVersion: 2
m_LocalRotation: {x: 0.11851885, y: 0.6224197, z: -0.09609433, w: 0.7676672}
m_LocalRotation: {x: 0.11851885, y: 0.6224197, z: -0.09609434, w: 0.7676672}
m_LocalPosition: {x: -1.3505859, y: -4.517355, z: -13.63147}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -1467,7 +1467,7 @@ MonoBehaviour:
LensShift: {x: 0, y: 0}
GateFit: 1
FocusDistance: 8.93528
m_SensorSize: {x: 1, y: 1}
m_SensorSize: {x: 36, y: 24}
Iso: 50
ShutterSpeed: 0.0005
Aperture: 2.2
@ -2875,7 +2875,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1178814724}
serializedVersion: 2
m_LocalRotation: {x: 0.11851884, y: 0.6224197, z: -0.096094325, w: 0.7676672}
m_LocalRotation: {x: 0.11851884, y: 0.6224197, z: -0.0960943, w: 0.76766723}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -4093,6 +4093,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_VCamList: []
m_CMBrain: {fileID: 470663204}
m_Parent: {fileID: 953333219}
--- !u!1 &1802313638
GameObject:
m_ObjectHideFlags: 0

42
Assets/7_Scripts/Camera/CameraManager.cs

@ -14,6 +14,8 @@ public class CameraManager : MonoBehaviour
public CinemachineBrain m_CMBrain;
public GameObject m_Parent;
private void Awake()
{
if (instance != null && instance != this)
@ -29,21 +31,35 @@ public class CameraManager : MonoBehaviour
private void Start()
{
// Get all virtual camera objects in Unity
CompleteVCList();
CompleteVCChildList();
}
private void Update()
{
// Check if a key between 0 and 9 is pressed
for (int i = 0; i <= 9; i++)
{
if (Input.GetKeyDown(KeyCode.Alpha0 + i))
{
// Set priorities based on the key pressed
SetCameraPriorities(i);
break; // Exit loop after handling the key press
}
}
SetCullingMask();
}
private void CompleteVCChildList()
{
m_VCamList = m_Parent.GetComponentsInChildren<CinemachineVirtualCamera>();
}
private void CompleteVCList() => m_VCamList = FindObjectsByType<CinemachineVirtualCamera>(FindObjectsSortMode.None);
private void SetCullingMask()
{
CinemachineVirtualCamera cam = (CinemachineVirtualCamera) m_CMBrain.ActiveVirtualCamera;
GameObject obj = cam.gameObject;
string tag = obj.tag;
GameObject cam = m_CMBrain.ActiveVirtualCamera.VirtualCameraGameObject;
string tag = cam.tag;
Camera mainCamera = m_CMBrain.OutputCamera;
if (tag.Contains("surviellance"))
@ -55,4 +71,22 @@ public class CameraManager : MonoBehaviour
mainCamera.cullingMask = LayerMask.GetMask("Default", "TransparentFX", "Ignore Raycast", "Water", "UI", "Rig");
}
}
private void SetCameraPriorities(int keyPressed)
{
if (keyPressed < m_VCamList.Length)
{
m_VCamList[keyPressed].Priority = 1;
//Debug.Log($"{m_VCamList[keyPressed].gameObject.name}");
}
// Assign priority 2 to all other virtual cameras
for (int i = 0; i < m_VCamList.Length; i++)
{
if (i != keyPressed)
{
m_VCamList[i].Priority = 2;
}
}
}
}

0
Assets/7_Scripts/CameraSwitchScript.cs → Assets/7_Scripts/Camera/CameraSwitchScript.cs

0
Assets/7_Scripts/CameraSwitchScript.cs.meta → Assets/7_Scripts/Camera/CameraSwitchScript.cs.meta

2
Assets/ML-Agents/Timers/Beep_timers.json

@ -1 +1 @@
{"count":1,"self":6.6123047999999995,"total":8.3104437,"children":{"InitializeActuators":{"count":1,"self":0.0010063,"total":0.0010063,"children":null},"InitializeSensors":{"count":1,"self":0.0025082,"total":0.0025082,"children":null},"AgentSendState":{"count":134,"self":0.0035207,"total":0.022649,"children":{"CollectObservations":{"count":27,"self":0.0010041,"total":0.0010041,"children":null},"WriteActionMask":{"count":27,"self":0.0010014,"total":0.0010014,"children":null},"RequestDecision":{"count":27,"self":0.0171228,"total":0.0171228,"children":null}}},"DecideAction":{"count":134,"self":0.0808026,"total":1.6694620999999998,"children":{"RayPerceptionSensor.Perceive":{"count":27,"self":1.5886595,"total":1.5886595,"children":null}}},"AgentAct":{"count":134,"self":0.0025131999999999997,"total":0.0025131999999999997,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1710175836","unity_version":"2023.2.8f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2023.2.8f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_02-Beep\\4_Unity\\Beep Final Git\\beep-final -useHub -hubIPC -cloudEnvironment production","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.3.0-exp.3","scene_name":"Beep","end_time_seconds":"1710175844"}}
{"count":1,"self":6.6528756,"total":7.7418388,"children":{"InitializeActuators":{"count":1,"self":0.0005034,"total":0.0005034,"children":null},"InitializeSensors":{"count":1,"self":0.0015072999999999998,"total":0.0015072999999999998,"children":null},"AgentSendState":{"count":94,"self":0.0035085999999999997,"total":0.024592,"children":{"CollectObservations":{"count":19,"self":0.0020052,"total":0.0020052,"children":null},"WriteActionMask":{"count":19,"self":0,"total":0,"children":null},"RequestDecision":{"count":19,"self":0.0190782,"total":0.0190782,"children":null}}},"DecideAction":{"count":94,"self":0.0960755,"total":1.0588469999999999,"children":{"RayPerceptionSensor.Perceive":{"count":19,"self":0.9627715,"total":0.9627715,"children":null}}},"AgentAct":{"count":94,"self":0.0035134999999999997,"total":0.0035134999999999997,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1710177958","unity_version":"2023.2.8f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2023.2.8f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_02-Beep\\4_Unity\\Beep Final Git\\beep-final -useHub -hubIPC -cloudEnvironment production","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.3.0-exp.3","scene_name":"Beep","end_time_seconds":"1710177966"}}
Loading…
Cancel
Save