void ShowCtrlPanel() { if (m_CurAnimation != null && m_CurAnimation.IsPlaying()) { m_CurAnimation.Kill(); } m_CurAnimation = DOTween.To(() => m_CanvasGroup.alpha, x => m_CanvasGroup.alpha = x, 1, m_AnimationTime).OnStart( () => { m_CtrlPanel.enabled = true; //Update the position of the controller panel at the begining. float distance = Vector3.Distance(m_CtrlPanel.transform.localPosition, m_Camera.transform.localPosition); m_CtrlPanel.transform.localPosition = m_Camera.transform.localPosition + m_Camera.transform.forward * distance; m_CtrlPanel.transform.LookAt(m_Camera.transform); m_CtrlPanel.transform.Rotate(new Vector3(0, 180, 0), Space.Self); m_CurPanelState = ResourceUtilities.PANELSTATE.SHOWING; } ).OnComplete(() => { m_CurPanelState = ResourceUtilities.PANELSTATE.ISSHOWN; }).SetEase(Ease.InExpo); }
void ListenCtrlPanelState() { if (!m_CtrlPanel) { Debug.LogError("VRDemoManipulator ShowCtrlPanel controller Panel is null."); } else if (!m_Player) { Debug.LogError("VRDemoManipulator ShowCtrlPanel player is null."); } else if (!m_Camera) { Debug.LogError("VRDemoManipulator ShowCtrlPanel camera is null."); } switch (m_CurPanelState) { case ResourceUtilities.PANELSTATE.NEEDSHOW: ShowCtrlPanel(); break; case ResourceUtilities.PANELSTATE.SHOWING: case ResourceUtilities.PANELSTATE.ISSHOWN: if (m_Camera.transform.localEulerAngles.x < m_ShowAngle) { m_CurPanelState = ResourceUtilities.PANELSTATE.NEEDHIDE; } break; case ResourceUtilities.PANELSTATE.NEEDHIDE: HideCtrlPanel(); break; case ResourceUtilities.PANELSTATE.HIDING: case ResourceUtilities.PANELSTATE.ISHIDDEN: if (m_Camera.transform.localEulerAngles.x >= m_ShowAngle && m_Camera.transform.localEulerAngles.x < 180) { m_CurPanelState = ResourceUtilities.PANELSTATE.NEEDSHOW; } break; default: break; } }
void HideCtrlPanel() { if (m_CurAnimation != null && m_CurAnimation.IsPlaying()) { m_CurAnimation.Kill(); } m_CurAnimation = DOTween.To(() => m_CanvasGroup.alpha, x => m_CanvasGroup.alpha = x, 0, m_AnimationTime).OnStart( () => { m_CurPanelState = ResourceUtilities.PANELSTATE.HIDING; } ).OnComplete(() => { m_CtrlPanel.enabled = false; m_CurPanelState = ResourceUtilities.PANELSTATE.ISHIDDEN; }).SetEase(Ease.OutExpo); }