You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
using UnityEngine; |
|
/// <summary> |
|
/// 照明车控制 |
|
/// </summary> |
|
public class ZhaoMingCheController : MonoBehaviour |
|
{ |
|
public GameObject Arm; |
|
public GameObject Light; |
|
|
|
private Vector3 armRot; |
|
private Vector3 lightRot; |
|
|
|
private float rotSpeed = 40f; |
|
|
|
public void InitData() |
|
{ |
|
Arm = transform.Find("Scene/Arm").gameObject; |
|
Light = Arm.transform.Find("Light").gameObject; |
|
} |
|
private void Start() |
|
{ |
|
armRot = Arm.transform.localEulerAngles; |
|
lightRot = Light.transform.localEulerAngles; |
|
} |
|
private void LateUpdate() |
|
{ |
|
|
|
if (SelectionManager.IsContains(gameObject)) |
|
{ |
|
if (Input.GetKey(PowerManager.Instance.down)) |
|
{ |
|
Arm.transform.Rotate(Time.deltaTime * rotSpeed, 0, 0); |
|
} |
|
else if (Input.GetKey(PowerManager.Instance.up)) |
|
{ |
|
Arm.transform.Rotate(-Time.deltaTime * rotSpeed, 0, 0); |
|
} |
|
|
|
if (Input.GetKey(PowerManager.Instance.leftR)) |
|
{ |
|
Light.transform.Rotate(0, 0, -Time.deltaTime * rotSpeed); |
|
} |
|
else if (Input.GetKey(PowerManager.Instance.rightR)) |
|
{ |
|
Light.transform.Rotate(0, 0, Time.deltaTime * rotSpeed); |
|
} |
|
|
|
if (Input.GetKeyDown(PowerManager.Instance.reset)) |
|
OnReset(); |
|
} |
|
|
|
} |
|
|
|
private void OnReset() |
|
{ |
|
Arm.transform.localEulerAngles = armRot; |
|
Light.transform.localEulerAngles = lightRot; |
|
} |
|
}
|
|
|