12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using UnityEngine;
- [AddComponentMenu("NGUI/Examples/Window Auto-Yaw")]
- public class WindowAutoYaw : MonoBehaviour
- {
- private void OnDisable()
- {
- this.mTrans.localRotation = Quaternion.identity;
- }
- private void OnEnable()
- {
- if (this.uiCamera == null)
- {
- this.uiCamera = NGUITools.FindCameraForLayer(base.gameObject.layer);
- }
- this.mTrans = base.transform;
- }
- private void Update()
- {
- if (this.uiCamera != null)
- {
- Vector3 vector = this.uiCamera.WorldToViewportPoint(this.mTrans.position);
- this.mTrans.localRotation = Quaternion.Euler(0f, (vector.x * 2f - 1f) * this.yawAmount, 0f);
- }
- }
- public int updateOrder;
- public Camera uiCamera;
- public float yawAmount = 20f;
- private Transform mTrans;
- }
|