void Update() { if (!MapController.Instance) { return; } activeButton = MapController.Instance.ActiveButton; if (!mainCanvas) { mainCanvas = MapController.Instance.parentCanvas; } if (activeButton && mainCanvas) { Group.anchoredPosition = RectTransformToCanvasSpaceCenterCenter(activeButton.GetComponent <RectTransform>(), mainCanvas); topHalf = (flip) ? Group.anchoredPosition.y > 0 : false; groupAngleZ = (topHalf) ? Mathf.LerpAngle(groupAngleZ, 180, Time.deltaTime * 2.0f) : Mathf.LerpAngle(groupAngleZ, 0, Time.deltaTime * 2.0f); maskRect.localRotation = Quaternion.Euler(-Group.localRotation.eulerAngles); if (rotate) { Group.localRotation = Quaternion.Euler(new Vector3(0, 0, groupAngleZ + 5f * Mathf.Sin(2f * Time.time))); } else { Group.localRotation = Quaternion.Euler(new Vector3(0, 0, topHalf ? 180 : 0)); } } }
void Update() { activeButton = MapController.Instance.ActiveButton; if (!mainCanvas) { mainCanvas = MapController.Instance.parentCanvas; } if (activeButton && mainCanvas) { Group.transform.position = activeButton.transform.position; // Group.anchoredPosition = Coordinats.RectTransformToCanvasSpaceCenterCenter(activeButton.GetComponent<RectTransform>(), MapController.Instance.parentCanvas); topHalf = Group.anchoredPosition.y > 0; groupAngleZ = (topHalf) ? Mathf.LerpAngle(groupAngleZ, 180, Time.deltaTime * 2.0f) : Mathf.LerpAngle(groupAngleZ, 0, Time.deltaTime * 2.0f); maskRect.localRotation = Quaternion.Euler(-Group.localRotation.eulerAngles); Group.localRotation = Quaternion.Euler(new Vector3(0, 0, groupAngleZ + 5f * Mathf.Sin(2f * Time.time))); } }