private static void NewEventArea(AudioEvent audioevent) { var defaultAlignment = GUI.skin.label.alignment; EditorGUILayout.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleLeft; EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); Rect lastArea = GUILayoutUtility.GetLastRect(); lastArea.height *= 1.5f; if (GUI.Button(lastArea, "Click or drag here to add event")) { ShowCreationContext(audioevent); } if (Event.current.type != EventType.Repaint) { var dragging = DragAndDrop.objectReferences; OnDragging.OnDraggingObject(dragging, lastArea, objects => AudioEventWorker.CanDropObjects(audioevent, dragging), objects => AudioEventWorker.OnDrop(audioevent, dragging)); } GUI.skin.label.alignment = defaultAlignment; }
private void OnMouseDrag() { AdjustPointerID(); if (!CheckPointerRelativePosition(out Vector2 pt)) { return; } if (opStatus == "down") { if ((pt - dragFrom).sqrMagnitude <= 0.1f) { return; } opStatus = "dragging"; OnStartDragging.SC(dragFrom.x, dragFrom.y); lastDraggingPos = dragFrom; draggingOffset = Vector2.zero; } else if (opStatus == "dragging") { var dPos = pt - lastDraggingPos; lastDraggingPos = pt; draggingOffset += dPos; OnDragging.SC(dragFrom.x, dragFrom.y, dragFrom.x + draggingOffset.x, dragFrom.y + draggingOffset.y); } }
public override void UpdateSelf(GameTime gameTime) { base.UpdateSelf(gameTime); this.Text = BindingElement.Name; if (_isDragging) { OnDragging?.Invoke(new UIActionEvent(this, gameTime.TotalGameTime), this); } }
void SetDragPos(PointerEventData ed) { if (!IsFocus.Value || !_isDragged) { return; } Vector2 worldPos = _camera.ScreenToWorldPoint(ed.position); OnDragging?.Invoke(worldPos + offset); }
public override void UpdateSelf(GameTime gameTime) { if (IsDragging) { Position = ScreenPositionToParentAR(Main.MouseScreen - _dragOffset); OnDragging?.Invoke(new UIDraggingEvent(this, Position - _dragStartPos, gameTime.TotalGameTime), this); } if (IsMouseHover || IsDragging) { CursorChange(); } base.UpdateSelf(gameTime); }
public bool OnDrag(PointerEventData eventData) { if (_isDraggingPoint) { SetDraggedPosition(eventData); OnDragging?.Invoke(this, new EventArgs(eventData, isPointEvent: true)); } else if (_isDraggingOutHandle) { SetDraggedAngle(eventData); OnDragging?.Invoke(this, new EventArgs(eventData, isOutHandleEvent: true)); } else if (_isDraggingInHandle) { SetDraggedAngle(eventData); OnDragging?.Invoke(this, new EventArgs(eventData, isInHandleEvent: true)); } else { return(!IsEventOutside(eventData)); } return(true); }
private void MoveCamera() { OnDragging?.Invoke(); // Get the new position of the mouse relative to the _touchOrigin. Vector3 newPosition; newPosition = _camera.ScreenToViewportPoint(Input.mousePosition) - _touchOrigin; //Checks if the mouse is outside the draggingThreshold if ((Mathf.Abs(newPosition.x) > _draggingThreshold || Mathf.Abs(newPosition.y) > _draggingThreshold) || _isDragging) { _isDragging = true; // Move the Camera. transform.position = new Vector3( _previousPosition.x + -newPosition.x * _draggingSpeedMultiplier * 10, transform.position.y, _previousPosition.z + -newPosition.y * _draggingSpeedMultiplier * 10 ); // Save the updated position as new origin position SaveOriginPositions(); } }
private static bool DrawContent(AudioEvent audioevent, Rect area) { Rect selectedBackground = drawArea; selectedBackground.y += 2; DrawBackground(selectedBackground); GUI.skin.label.alignment = TextAnchor.MiddleCenter; bool repaint = false; EditorGUILayout.BeginVertical(); for (int i = 0; i < audioevent.ActionList.Count; ++i) { var currentAction = audioevent.ActionList[i]; Rect lastArea = EditorGUILayout.BeginHorizontal(GUILayout.Height(20)); if (i == 0) { Rect actionArea = lastArea; actionArea.width = 100; actionArea.height = 20; actionArea.y -= 20; EditorGUI.LabelField(actionArea, "Action", EditorStyles.boldLabel); } if (currentAction != null) { if (GUILayout.Button( Enum.GetName(typeof(EventActionTypes), (int)currentAction.EventActionType) .AddSpacesToSentence(), GUILayout.Width(110))) { ShowChangeContext(audioevent, currentAction); Event.current.Use(); } } else { EditorGUILayout.LabelField("Missing"); GUI.enabled = false; } EditorGUILayout.BeginVertical(GUILayout.Height(20)); GUILayout.Label("", GUILayout.Height(0)); //Aligns it to the center by creating a small vertical offset, by setting the height to zero if (currentAction != null && currentAction.EventActionType != EventActionTypes.StopAll) { EditorGUILayout.LabelField(currentAction.ObjectName); } EditorGUILayout.EndHorizontal(); Rect dragArea = GUILayoutUtility.GetLastRect(); if (i == 0) { Rect actionArea = dragArea; actionArea.width = 100; actionArea.height = 20; actionArea.y -= 20; EditorGUI.LabelField(actionArea, "Data", EditorStyles.boldLabel); } if (currentAction is EventAudioAction) { AudioNode dragged = OnDragging.DraggingObject <AudioNode>(dragArea, node => node.IsPlayable); if (dragged != null) { (currentAction as EventAudioAction).Node = dragged; } } else if (currentAction is EventBankAction) { AudioBankLink dragged = OnDragging.DraggingObject <AudioBankLink>(dragArea, bank => bank.Type == AudioBankTypes.Link); if (dragged != null) { (currentAction as EventBankAction).BankLink = dragged; } } else if (currentAction is EventBusAction) { AudioBus dragged = OnDragging.DraggingObject <AudioBus>(dragArea, bus => true); if (dragged != null) { (currentAction as EventBusAction).Bus = dragged; } } EditorGUILayout.Separator(); EditorGUILayout.Separator(); Rect rightArea = EditorGUILayout.BeginHorizontal(GUILayout.Width(area.width - 100)); rightArea.x -= 150; rightArea.y += 3; rightArea.width = 80; //rightARea.height -= 6; if (GUI.Button(rightArea, "Find")) { SearchHelper.SearchFor(currentAction); } rightArea.x += 90; rightArea.width = 30; if (GUI.Button(rightArea, "X")) { if (audioevent.ActionList[i] != null) { AudioEventWorker.DeleteActionAtIndex(audioevent, i); } else { audioevent.ActionList.SwapRemoveAt(i); --i; } } if (Event.current.ClickedWithin(lastArea)) { drawArea = lastArea; audioEventAction = currentAction; Event.current.Use(); } //if (audioEventAction == null || ( Event.current.type == EventType.MouseDown && lastArea.Contains(Event.current.mousePosition))) //{ // drawArea = lastArea; // audioEventAction = currentAction; //} GUILayout.Label(""); //EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); GUI.enabled = true; } EditorGUILayout.EndVertical(); return(repaint); }
public void OnEndDrag(PointerEventData eventData) { OnDragging.Invoke(eventData.position - _startPosition, eventData); OnDragEnd.Invoke(eventData.position - _startPosition, eventData); }
public void OnDrag(PointerEventData eventData) { _currentDragPoint = eventData.position; UpdateDragDto(); OnDragging?.Invoke(_dragDto); }
protected void CallDragging(ScreenButton sender, Vector2 value) { OnDragging?.Invoke(this, value); }
public void OnDrag(PointerEventData eventData) { SetDraggedPosition(eventData); OnDragging?.Invoke(this, new PointerEventArgs(eventData)); }