// protected override protected virtual void Update() { // base.Update(); if (Application.isPlaying) { if ((object)parent == null) { if (UIManager.UIIsLastInStack(this)) { // if (!UIPopups.popupOpen || IsPopup()) { if (isActive) { // was having issues with input that opens ui, counting towards newly opened ui if (enabledFrame) { enabledFrame = false; return; } // Vector2Int action = new Vector2Int(-1,-1); Vector2Int action = UIInput.GetUIActions(GetUsedActions()); // if (actionHandler == null) { // action = DefaultActionHandler(); // } // else { // action = actionHandler(); // } if (action.x >= 0) { // Debug.Log("Doing Action"); DoAction(action); } } } } } }
public void OnValueChanged(float value) { // amountText.SetText( "<b>" + value.ToString() + "</b>");//, -1 ); amountText.SetText(value.ToString()); //, -1 ); if (Application.isPlaying) { BroadcastSelectEvent(null, new object[] { value }); if (!extraSpeedUp) { if (Time.unscaledTime - lastTimeUntouched > timeForSpeedUp) { float speedUpValue = (Time.unscaledTime - lastTimeUntouched) * speedUpFactor; extraSpeedUp = true; slider.value += speedUpValue * UIInput.GetHorizontalAxis(); } // if (speedUpValue != 0 ) { // } } extraSpeedUp = false; } }
void Update() { base.Update(); if (!Application.isPlaying) { return; } if (!isActive) { return; } if (!GameManager.playerExists) { return; } baseMapParameters.UpdateMapMarkers(GameManager.playerActor.GetPosition()); zoom -= UIInput.mouseScrollDelta.y * zoomSpeed * Time.deltaTime; zoom = Mathf.Clamp(zoom, 1, maxZoom); float z = 1f / zoom; float speed = moveSpeed * Time.deltaTime * z; float inputX = UIInput.GetHorizontalAxis(); float inputY = UIInput.GetVerticalAxis(); if (unsnapProhibit) { if (inputX == 0 && inputY == 0 || Time.time - snappedTime >= unsnapTime) { unsnapProhibit = false; } inputX = 0; inputY = 0; } move.x = Mathf.Clamp(move.x + inputX * speed, -.5f, .5f); move.y = Mathf.Clamp(move.y + inputY * speed, -.5f, .5f); float zOffset = (-0.5f) * z + 0.5f; Vector2 move2 = move * 2; float halfMapUI = mapSize * .5f; float halfMapUIZoom = halfMapUI * zoom; for (int k = 0; k < baseMapParameters.mapMarkers.Count; k++) { // foreach (var k in mapMarkers.Keys) { MapMarker m = baseMapParameters.mapMarkers[k]; Vector3 wPos = m.GetMarkerPosition(); Vector2 uiPos = (((new Vector2(wPos.x, wPos.z) - mapCenter) / mapRadius) - move2) * halfMapUIZoom; bool markerEnabled = uiPos.x <= halfMapUI && uiPos.x >= -halfMapUI && uiPos.y <= halfMapUI && uiPos.y >= -halfMapUI; m.EnableMapMarker(markerEnabled); if (markerEnabled && uiPos.sqrMagnitude <= snapDist) { if (selectedMarker == null) // && (markerToSelect == null || markerToSelect == currentWaypointMarker)) { // markerToSelect = m; { move += (uiPos / halfMapUI) / 2 * z; uiPos = Vector2.zero; // // move.x += (uiPos.x / halfMapUI)/2 * z; // // move.y += (uiPos.y / halfMapUI)/2 * z; unsnapProhibit = true; snappedTime = Time.time; SelectMarker(m); } } else { if (selectedMarker == m) { DeselectMarker(m); } } if (markerEnabled) { if (m.showRotation) { if (m.mainGraphic != null) { Vector3 fwd = m.GetMarkerForward(); fwd.y = 0; float angle = Vector3.Angle(fwd, Vector3.forward); if (Vector3.Angle(fwd, Vector3.right) > 90) { angle *= -1; } m.mainGraphic.rectTransform.localRotation = Quaternion.Euler(0, 0, -angle); } } m.rectTransform.anchoredPosition = uiPos; } } mapImage.uvRect = new Rect(move.x + zOffset, move.y + zOffset, z, z); if (UIInput.GetSubmitDown()) { AddWaypoint(zOffset); } }