78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class UIScene : MonoBehaviour
|
|
{
|
|
public static UIScene Instance;
|
|
/// <summary>
|
|
/// 主相机
|
|
/// </summary>
|
|
public Camera ui_camera;
|
|
/// <summary>
|
|
/// 相机Transform组件
|
|
/// </summary>
|
|
public Transform camera_transform;
|
|
|
|
private Vector3 _camera_init_position;
|
|
private Quaternion _camera_init_rotation;
|
|
/// <summary>
|
|
/// 相机初始位置
|
|
/// </summary>
|
|
public Vector3 camera_init_position { get { return _camera_init_position; } set { camera_transform.position = _camera_init_position = value; } }
|
|
/// <summary>
|
|
/// 相机初始角度
|
|
/// </summary>
|
|
public Quaternion camera_init_rotation { get { return _camera_init_rotation; } set { camera_transform.rotation = _camera_init_rotation = value; } }
|
|
/// <summary>
|
|
/// 相机移动脚本
|
|
/// </summary>
|
|
public CameraMove camera_move;
|
|
/// <summary>
|
|
/// 音频播放器
|
|
/// </summary>
|
|
public AudioSource audio_source;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
|
|
public void ResetCameraTransform()
|
|
{
|
|
if (GameManager.current_component_type == ComponentType.无人机)
|
|
{
|
|
CameraController.instance.SetTransform(camera_init_position, camera_init_rotation);
|
|
}
|
|
else if (GameManager.current_component_type == ComponentType.机器人)
|
|
{
|
|
CameraController.instance.SetTransform(camera_init_position, camera_init_rotation);
|
|
}
|
|
else
|
|
{
|
|
GameObject.Find("FreeLookCameraRig").transform.position = new Vector3(0, 0, 0);
|
|
GameObject.Find("FreeLookCameraRig").transform.eulerAngles = new Vector3(0, 0, 0);
|
|
GameObject.Find("FreeLookCameraRig").transform.GetChild(0).eulerAngles = new Vector3(0, 0, 0);
|
|
}
|
|
}
|
|
|
|
|
|
public void Reset()
|
|
{
|
|
if (GameManager.current_component_type == ComponentType.无人机)
|
|
{
|
|
camera_transform = GameObject.Find("All").transform.GetChild(0).transform;
|
|
}
|
|
else if (GameManager.current_component_type == ComponentType.机器人)
|
|
{
|
|
camera_transform = GameObject.Find("Camera").transform;
|
|
}
|
|
else
|
|
{
|
|
camera_transform = GameObject.Find("FreeLookCameraRig").transform;
|
|
}
|
|
}
|
|
}
|