using System; using UnityEngine; public class VRCommandMenuDrawManager : VRWfChangeCanvas { public override void ChangeDeviceMode(GameMain.VRDeviceType devideType) { this.isVisible = true; this.ChangeDrawMode(devideType != GameMain.VRDeviceType.NON); if (devideType == GameMain.VRDeviceType.RIFT_TOUCH || devideType == GameMain.VRDeviceType.VIVE) { this.updateWorldPosition = false; } else { this.updateWorldPosition = true; } } public override void ChangeDrawMode(bool worldMode) { if (worldMode) { base.renderMode = RenderMode.WorldSpace; this.rectTransform.localPosition = Vector3.zero; this.rectTransform.localScale = new Vector3(0.0006f, 0.0006f, 1f); this.rectTransform.localRotation = Quaternion.identity; this.commandImageTransform.anchorMin = new Vector2(0.5f, 0.5f); this.commandImageTransform.anchorMax = new Vector2(0.5f, 0.5f); this.commandImageTransform.pivot = new Vector2(0.5f, 0.5f); this.commandImageTransform.anchoredPosition = new Vector2(-123.7f, 149.9f); this.backupPosition = this.commandImageTransform.anchoredPosition; } else { base.renderMode = RenderMode.ScreenSpaceOverlay; this.rectTransform.localScale = Vector3.one; this.rectTransform.localRotation = Quaternion.identity; this.commandImageTransform.anchorMin = Vector2.zero; this.commandImageTransform.anchorMax = Vector2.zero; this.commandImageTransform.pivot = new Vector2(0.5f, 0.5f); this.commandImageTransform.anchoredPosition = new Vector2(233f, 101f); this.backupPosition = this.commandImageTransform.anchoredPosition; } } protected override void FixedUpdate() { base.FixedUpdate(); if (!this.updateWorldPosition) { this.commandImageTransform.anchoredPosition = this.backupPosition + this.imagePositionOffset; this.rectTransform.localRotation = Quaternion.Euler(this.rotationOffset); } } [SerializeField] public RectTransform commandImageTransform; public Vector2 imagePositionOffset; public Vector3 rotationOffset; private Vector2 backupPosition; }