1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using UnityEngine;
- [RequireComponent(typeof(RectTransform))]
- [RequireComponent(typeof(Canvas))]
- [RequireComponent(typeof(CanvasGroup))]
- public abstract class VRWfChangeCanvas : MonoBehaviour
- {
- public virtual bool isVisible
- {
- get
- {
- return this.canvasGroup.alpha != 0f;
- }
- set
- {
- this.canvasGroup.alpha = (float)((!value) ? 0 : 1);
- }
- }
- protected RenderMode renderMode
- {
- get
- {
- return this.parentCanvas.renderMode;
- }
- set
- {
- this.parentCanvas.renderMode = value;
- if (this.parentCanvas.renderMode == RenderMode.ScreenSpaceOverlay)
- {
- this.parentCanvas.pixelPerfect = true;
- }
- }
- }
- protected virtual void Awake()
- {
- this.rectTransform = base.GetComponent<RectTransform>();
- this.parentCanvas = base.GetComponent<Canvas>();
- this.canvasGroup = base.GetComponent<CanvasGroup>();
- }
- public virtual void ChangeDeviceMode(GameMain.VRDeviceType devideType)
- {
- if (devideType == GameMain.VRDeviceType.NON || devideType == GameMain.VRDeviceType.RIFT || devideType == GameMain.VRDeviceType.FOVE)
- {
- this.isVisible = true;
- this.ChangeDrawMode(devideType != GameMain.VRDeviceType.NON);
- }
- else
- {
- this.isVisible = false;
- }
- }
- public abstract void ChangeDrawMode(bool worldMode);
- protected virtual void FixedUpdate()
- {
- if (!this.updateWorldPosition || this.parentCanvas.renderMode != RenderMode.WorldSpace || GameMain.Instance.OvrMgr == null)
- {
- return;
- }
- OvrCamera ovrCamera = GameMain.Instance.OvrMgr.OvrCamera;
- this.rectTransform.position = ovrCamera.m_goCenterEye.transform.position + ovrCamera.m_goCenterEye.transform.forward * this.distanceFromCamera;
- this.rectTransform.rotation = Quaternion.LookRotation(this.rectTransform.position - ovrCamera.m_goCenterEye.transform.position);
- }
- [SerializeField]
- [Tooltip("ワールド座標での位置を更新し続けるかどうか")]
- public bool updateWorldPosition = true;
- [SerializeField]
- [Tooltip("ワールド座標モードでのカメラからの距離")]
- public float distanceFromCamera = 0.2f;
- protected RectTransform rectTransform;
- protected CanvasGroup canvasGroup;
- protected Canvas parentCanvas;
- }
|