private void HandleDragAndDrop(UnityEngine.Event currentEvent, UnityEngine.Rect dropArea) { switch (currentEvent.type) { case UnityEngine.EventType.DragUpdated: if (dropArea.Contains(currentEvent.mousePosition)) { var DDData = GetAkDragDropData(); UnityEditor.DragAndDrop.visualMode = DDData != null ? UnityEditor.DragAndDropVisualMode.Link : UnityEditor.DragAndDropVisualMode.Rejected; currentEvent.Use(); } break; case UnityEngine.EventType.DragPerform: if (dropArea.Contains(currentEvent.mousePosition)) { var DDData = GetAkDragDropData(); UnityEditor.DragAndDrop.AcceptDrag(); if (DDData != null) { AkUtilities.SetByteArrayProperty(m_guidProperty[0], DDData.guid.ToByteArray()); var DDGroupData = DDData as AkDragDropGroupData; if (DDGroupData != null && m_guidProperty.Length > 1) { AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGroupData.groupGuid.ToByteArray()); } //needed for the undo operation to work UnityEngine.GUIUtility.hotControl = 0; } currentEvent.Use(); } break; case UnityEngine.EventType.DragExited: // clear dragged data UnityEditor.DragAndDrop.PrepareStartDrag(); break; } }
private float CalculateHoverTime(UnityEngine.Rect rect, UnityEngine.Vector3 mousePos) { if (rect.Contains(mousePos)) { return(0f); } var midPoint = (rect.yMin + rect.yMax) * 0.5f; var pointA = mousePos.y; return(UnityEngine.Mathf.Abs(midPoint - pointA) / 50f); }
private void HandleDragAndDrop(UnityEngine.Rect dropArea) { var currentEvent = UnityEngine.Event.current; if (currentEvent.type == UnityEngine.EventType.DragExited) { UnityEditor.DragAndDrop.PrepareStartDrag(); } else if (currentEvent.type == UnityEngine.EventType.DragUpdated || currentEvent.type == UnityEngine.EventType.DragPerform) { if (dropArea.Contains(currentEvent.mousePosition)) { var DDData = GetAkDragDropData(); if (currentEvent.type == UnityEngine.EventType.DragUpdated) { UnityEditor.DragAndDrop.visualMode = DDData != null ? UnityEditor.DragAndDropVisualMode.Link : UnityEditor.DragAndDropVisualMode.Rejected; } else { UnityEditor.DragAndDrop.AcceptDrag(); if (DDData != null) { AkUtilities.SetByteArrayProperty(m_guidProperty[0], DDData.guid.ToByteArray()); m_IDProperty[0].intValue = DDData.ID; var DDGroupData = DDData as AkDragDropGroupData; if (DDGroupData != null) { if (m_guidProperty.Length > 1) { AkUtilities.SetByteArrayProperty(m_guidProperty[1], DDGroupData.groupGuid.ToByteArray()); } if (m_IDProperty.Length > 1) { m_IDProperty[1].intValue = DDGroupData.groupID; } } // needed for the undo operation to work UnityEngine.GUIUtility.hotControl = 0; } } currentEvent.Use(); } } }
private void HandleDragAndDrop(UnityEditor.SerializedProperty wwiseObjectReference, UnityEngine.Rect dropArea) { var currentEvent = UnityEngine.Event.current; if (currentEvent.type == UnityEngine.EventType.DragExited) { UnityEditor.DragAndDrop.PrepareStartDrag(); } else if ((currentEvent.type == UnityEngine.EventType.DragUpdated || currentEvent.type == UnityEngine.EventType.DragPerform) && dropArea.Contains(currentEvent.mousePosition)) { var reference = UnityEditor.DragAndDrop.GetGenericData(AkDragDropHelper.DragDropIdentifier) as WwiseObjectReference; if (reference != null && reference.WwiseObjectType != WwiseObjectType) { reference = null; } if (currentEvent.type == UnityEngine.EventType.DragUpdated) { UnityEditor.DragAndDrop.visualMode = reference != null ? UnityEditor.DragAndDropVisualMode.Link : UnityEditor.DragAndDropVisualMode.Rejected; } else { UnityEditor.DragAndDrop.AcceptDrag(); if (reference != null) { wwiseObjectReference.objectReferenceValue = reference; } UnityEngine.GUIUtility.hotControl = 0; } currentEvent.Use(); } }
private void HandleDragAndDrop(UnityEditor.SerializedProperty wwiseObjectReference, UnityEngine.Rect dropArea) { var currentEvent = UnityEngine.Event.current; if (!dropArea.Contains(currentEvent.mousePosition)) { return; } if (currentEvent.type != UnityEngine.EventType.DragUpdated && currentEvent.type != UnityEngine.EventType.DragPerform) { return; } var reference = AkWwiseTypes.DragAndDropObjectReference; if (reference != null && reference.WwiseObjectType != WwiseObjectType) { reference = null; } UnityEditor.DragAndDrop.visualMode = reference != null ? UnityEditor.DragAndDropVisualMode.Link : UnityEditor.DragAndDropVisualMode.Rejected; if (currentEvent.type == UnityEngine.EventType.DragPerform) { UnityEditor.DragAndDrop.AcceptDrag(); if (reference != null) { SetSerializedObject(wwiseObjectReference, reference); } UnityEditor.DragAndDrop.PrepareStartDrag(); UnityEngine.GUIUtility.hotControl = 0; } currentEvent.Use(); }
public bool HasFocus(UnityEngine.Vector2 mousePos) { var rect = new UnityEngine.Rect(m_scrollView.x, m_scrollView.y, 600, 900); // Width, Height); return(rect.Contains(mousePos)); }
public static bool ContainsMouse(this UnityEngine.Rect window_rectangle) { UnityEngine.Vector3 mouse = UnityEngine.Input.mousePosition; mouse.y = UnityEngine.Screen.height - mouse.y; return(window_rectangle.Contains(mouse)); }
public bool DrawPreview(UnityEngine.Rect position) { UnityEngine.Texture texture = GetTexture(); if (texture != null) { UnityEngine.GUI.DrawTextureWithTexCoords(position, texture, GetPreviewFace()); } return(UnityEngine.Event.current.type == UnityEngine.EventType.MouseDown && position.Contains(UnityEngine.Event.current.mousePosition)); }