void Update() { AdjustAngleBasedOnScreenPos(); // Update selection colours for (int i = 0; i < m_MenuObjects.Count; i++) { if (!m_MenuObjects[i].gameObject.activeSelf) { continue; } } if (m_State == State.Activating || m_State == State.Active) { } if (m_State == State.Activating) { m_RadLayout.UpdateFDistance(Mathf.Lerp(m_RadLayout.fDistance, m_TargetRadius, Time.deltaTime * m_Smoothing)); float norm = m_RadLayout.fDistance / m_Radius; SetAllObjectFades(Mathf.Pow(norm, 5)); if (Mathf.Abs(m_RadLayout.fDistance - m_TargetRadius) < 2) { m_State = State.Active; } } else if (m_State == State.Active) { if (Vector3.Distance(Input.mousePosition, transform.position) < m_DeadZone) { m_MenuText.text = m_MenuName; m_OptionSelected = false; } else { m_SelectedIndex = FindClosestButtonIndex(); m_OptionSelected = true; } // if (Input.GetMouseButtonUp(1)) // DeactivateMenu(); } else if (m_State == State.Deactivating) { float norm = (m_Radius - m_RadLayout.fDistance) / m_Radius; norm = 1 - norm; SetAllObjectFades(Mathf.Pow(norm, 5)); m_RadLayout.UpdateFDistance(Mathf.Lerp(m_RadLayout.fDistance, m_TargetRadius, Time.deltaTime * m_Smoothing)); if (Mathf.Abs(m_RadLayout.fDistance - m_TargetRadius) < 2) { m_State = State.Deactivated; for (int i = 0; i < m_MenuObjects.Count; i++) { m_MenuObjects[i].gameObject.SetActive(false); } if (m_HideInactive) { transform.position = Vector3.right * Screen.width * 3; } } } }
void Update() { AdjustAngleBasedOnScreenPos(); // Update selection colours for (int i = 0; i < m_MenuObjects.Count; i++) { if (!m_MenuObjects[i].gameObject.activeSelf) { continue; } if (!m_OptionSelected) { m_MenuObjects[i].GetComponent <Image>().color = m_BGCol; m_MenuObjects[i].GetComponentInChildren <Text>().color = m_TextCol; } else if (i != m_SelectedIndex) { m_MenuObjects[i].GetComponent <Image>().color = m_BGCol; m_MenuObjects[i].GetComponentInChildren <Text>().color = m_TextCol; } else { m_MenuObjects[i].GetComponent <Image>().color = m_FGCol; m_MenuObjects[i].GetComponentInChildren <Text>().color = m_TextCol; } } if (m_State == State.Activating || m_State == State.Active) { if (m_OptionSelected) { MainButton.GetComponent <Image>().color = Color.Lerp(MainButton.image.color, m_BGCol, Time.deltaTime * m_Smoothing); } } else { MainButton.GetComponent <Image>().color = Color.Lerp(MainButton.image.color, m_FGCol, Time.deltaTime * m_Smoothing); } if (m_State == State.Activating) { m_RadLayout.UpdateFDistance(Mathf.Lerp(m_RadLayout.fDistance, m_TargetRadius, Time.deltaTime * m_Smoothing)); float norm = m_RadLayout.fDistance / m_Radius; SetButtonFade(Mathf.Pow(norm, 5)); if (Mathf.Abs(m_RadLayout.fDistance - m_TargetRadius) < 2) { m_State = State.Active; } if (Input.GetMouseButtonUp(0)) { DeactivateMenu(); } } else if (m_State == State.Active) { if (Vector3.Distance(Input.mousePosition, transform.position) < m_DeadZone) { m_MenuText.text = m_MenuName; m_OptionSelected = false; } else { m_SelectedIndex = FindClosestButtonIndex(); m_MenuText.text = m_ButtonsNames[m_SelectedIndex]; m_OptionSelected = true; } if (Input.GetMouseButtonUp(0)) { DeactivateMenu(); } } else if (m_State == State.Deactivating) { float norm = (m_Radius - m_RadLayout.fDistance) / m_Radius; norm = 1 - norm; SetButtonFade(Mathf.Pow(norm, 5)); m_RadLayout.UpdateFDistance(Mathf.Lerp(m_RadLayout.fDistance, m_TargetRadius, Time.deltaTime * m_Smoothing)); if (Mathf.Abs(m_RadLayout.fDistance - m_TargetRadius) < 2) { m_State = State.Deactivated; for (int i = 0; i < m_ButtonsNames.Length; i++) { m_MenuObjects[i].gameObject.SetActive(false); } if (m_HideInactive) { transform.position = Vector3.right * float.MaxValue; } } } }