E_ElecCompetition/Electrical_inspectionCompet.../Assets/Script/KDLCamera/CameraManager.cs

52 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class CameraManager : MonoBehaviour
{
[SerializeField] Button Btn;
[SerializeField]Transform trans;
[SerializeField] Vector3 tempPos;
Quaternion RotePos;
TextMeshProUGUI text;
/// <summary>
/// 距喘県遨験峙
/// </summary>
/// <param name="to"></param>
public void BtnOnClick(Toggle to)
{
text = Btn.GetComponentInChildren<TextMeshProUGUI>();
to.onValueChanged.AddListener((x) =>
{
if (x)
{
OverLook();
text.text = "屎械篇夕";
}
else
{
ReturnLook();
text.text = "県遨夕";
}
});
tempPos = transform.position;
RotePos = transform.rotation;
}
void OverLook()
{
transform.GetComponent<Rigidbody>().useGravity = false;
transform.GetComponent<FirstPersonController>().enabled = false;
transform.position = trans.position;
transform.rotation = trans.rotation;
}
void ReturnLook()
{
transform.GetComponent<Rigidbody>().useGravity = true;
transform.GetComponent<FirstPersonController>().enabled = true;
transform.position= tempPos;
transform.rotation = RotePos;
}
}