protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); List <AssetBundleModel.AssetTreeItem> items = new List <AssetBundleModel.AssetTreeItem>(args.draggedItemIDs.Select(id => FindItem(id, rootItem) as AssetBundleModel.AssetTreeItem)); DragAndDrop.paths = items.Select(a => a.asset.Name).ToArray(); DragAndDrop.objectReferences = new UnityEngine.Object[] { }; DragAndDrop.SetGenericData("AssetListTreeSource", this); DragAndDrop.StartDrag("AssetListTree"); }
public void InitializeDrag(IList <int> indices) { if (CanDrag(indices)) { // TODO: convert indices to items DragAndDrop.PrepareStartDrag(); DragAndDrop.SetGenericData(DataIdentifier, indices[0]); DragAndDrop.paths = new string[] { PathIdentifier }; DragAndDrop.StartDrag("1 item"); } }
internal static void StartDrag(UnityEngine.Object obj, string label = null) { s_LastDraggedObject = obj; if (!s_LastDraggedObject) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new[] { s_LastDraggedObject }; DragAndDrop.StartDrag(label ?? s_LastDraggedObject.name); }
internal static void StartDrag(UnityEngine.Object[] objects, string label = null) { s_LastDraggedObjects = objects; if (s_LastDraggedObjects == null) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = s_LastDraggedObjects; DragAndDrop.StartDrag(label); }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); var draggedRows = GetRows().Where(item => args.draggedItemIDs.Contains(item.id)).ToList(); DragAndDrop.SetGenericData(DatatableDragID, draggedRows); DragAndDrop.objectReferences = new UnityEngine.Object[] { }; // this IS required for dragging to work string title = draggedRows.Count == 1 ? draggedRows[0].displayName : "< Multiple >"; DragAndDrop.StartDrag(title); }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = m_EmptyObjectList.ToArray(); var items = new List <AssetTreeItem>(args.draggedItemIDs.Select(x => FindItem(x, rootItem) as AssetTreeItem)); DragAndDrop.paths = items.Select(a => a.asset.fullAssetName).ToArray(); DragAndDrop.SetGenericData("AssetListTreeSource", this); DragAndDrop.StartDrag("AssetListTree"); }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); string[] paths = FindRows(args.draggedItemIDs) .Cast <BundleAssetTreeViewItem>() .Select(x => x.path) .ToArray(); DragAndDrop.paths = paths; DragAndDrop.SetGenericData(INSIDE_DRAG_KEY, true); DragAndDrop.StartDrag("move"); }
private void StartDrag() { if (!_selectedPrefab) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.paths = new[] { AssetDatabase.GetAssetPath(_selectedPrefab) }; DragAndDrop.objectReferences = new[] { _selectedPrefab }; DragAndDrop.StartDrag(_selectedPrefab.ToString()); _mouseDownTime = EditorApplication.timeSinceStartup; }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { base.SetupDragAndDrop(args); m_Dragged.Clear(); m_Dragged.AddRange(args.draggedItemIDs); DragAndDrop.objectReferences = new Object[0]; DragAndDrop.PrepareStartDrag(); DragAndDrop.StartDrag("Item view"); //DragAndDrop.visualMode = DragAndDropVisualMode.Move; }
private static void OnMouseMove(MouseMoveEvent evt) { if (evt.target is IDraggable draggable && draggable.DragState == DragState.Ready) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = draggable.DragObjects; DragAndDrop.SetGenericData(_dragData, draggable.DragData); DragAndDrop.StartDrag(draggable.DragText); draggable.DragState = DragState.Dragging; } }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { PrefabsListElement itemClicked = treeModel.Find(args.draggedItemIDs[0]); if (itemClicked.rustID != 0) { DragAndDrop.PrepareStartDrag(); DragAndDrop.SetGenericData(prefabName, itemClicked); DragAndDrop.StartDrag("Spawn Prefab"); PrefabManager.PrefabToSpawn = PrefabManager.Load(itemClicked.rustID); } }
public virtual void StartDrag(int draggedItemId, List <int> selectedItemIdList) { if (GenericDragId == null) { throw new NullReferenceException("You must specify a unique string for GenericDragId"); } DragAndDrop.PrepareStartDrag(); DragAndDrop.SetGenericData(GenericDragId, GetItemList(selectedItemIdList)); DragAndDrop.objectReferences = new UnityEngine.Object[0]; DragAndDrop.StartDrag(selectedItemIdList.Count + " item" + (selectedItemIdList.Count <= 1 ? string.Empty : "s")); }
public static void StartDrag(UnityEngine.Object[] objects, string[] paths, string label = null) { s_LastDraggedObjects = objects; if (paths == null || paths.Length == 0) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = s_LastDraggedObjects; DragAndDrop.paths = paths; DragAndDrop.StartDrag(label); }
private void StartDrag(Rect r, Row row) { DragAndDrop.PrepareStartDrag(); for (int i = 0; i < this.notes.Count; i++) { if (this.notes[i].row == row) { DragAndDrop.SetGenericData("n", this.notes[i]); break; } } }
private void PrepareDrag(EditorControl list) { ListViewCtrl list2 = list as ListViewCtrl; if (null == list) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new Object[] { null }; // 必须在这里初始化objectReferences,否则会遇到Unity drag & drop的bug DragAndDrop.SetGenericData("CustomDragFromList", list2.SelectItems); }
private static void HandleDragEvent(Object currentObject) { #if !UNITY_EDITOR_OSX DragAndDrop.PrepareStartDrag(); DragAndDrop.StartDrag(currentObject.name); DragAndDrop.objectReferences = new Object[] { currentObject }; if (EditorUtility.IsPersistent(currentObject)) { DragAndDrop.paths = new string[] { AssetDatabase.GetAssetPath(currentObject) }; } Event.current.Use(); #endif }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); var selectedBundles = new List <AssetBundleState.BundleInfo.TreeItem>(); foreach (var i in args.draggedItemIDs.Select(b => Utilities.FindItem <AssetBundleState.BundleInfo.TreeItem>(rootItem, b))) { GatherAllNodes(i, selectedBundles); } DragAndDrop.SetGenericData("AssetBundleState.BundleInfo.TreeItem", selectedBundles); DragAndDrop.visualMode = DragAndDropVisualMode.Move; DragAndDrop.StartDrag("AssetBundleTree"); }
private void OnElementDrag(ISearchableElement elem) { if (!elem.SupportDrag || elem.DragObject == null) { return; } DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new[] { elem.DragObject }; DragAndDrop.StartDrag("Dragging Object"); isDragging_ = true; }
private void EndDrag(UnityEngine.Object o) { if (Event.current.type == EventType.MouseDrag) { if (lastRect.Contains(Event.current.mousePosition)) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[] { o }; DragAndDrop.StartDrag(string.Format("Dragging {0}", o.ToString())); Event.current.Use(); } } }
public override void StartDrag(TreeViewItem draggedItem, List <int> draggedItemIDs) { DragAndDrop.PrepareStartDrag(); // DragAndDrop.objectReferences = ProjectWindowUtil.GetDragAndDropObjects(draggedItem.id, draggedItemIDs); // DragAndDrop.paths = ProjectWindowUtil.GetDragAndDropPaths(draggedItem.id, draggedItemIDs); if (DragAndDrop.objectReferences.Length > 1) { DragAndDrop.StartDrag("<Multiple>"); } else { DragAndDrop.StartDrag(ObjectNames.GetDragAndDropTitle(InternalEditorUtility.GetObjectFromInstanceID(draggedItem.id))); } }
//Drag and drop material input gui. Error reports and triggers autopopulation of textures public static void DropAreaGUI(Substance s) { Event evt = Event.current; Rect drop_area = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true)); GUI.Box(drop_area, "Drop Material Here", Styles.DragBox); switch (evt.type) { case EventType.DragUpdated: case EventType.DragPerform: if (!drop_area.Contains(evt.mousePosition)) { return; } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (evt.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); if (DragAndDrop.objectReferences.Length > 1) { Debug.LogWarning("<color=red>SBS:</color>\n" + "Field only accepts a single material."); DragAndDrop.PrepareStartDrag(); } else { if (DragAndDrop.objectReferences[0] is SubstanceArchive) { Debug.LogWarning("<color=red>SBS:</color>\n" + "Substance SBSAR not supported, input a material instead."); } else if (DragAndDrop.objectReferences[0] is Material) { foreach (Material mat in DragAndDrop.objectReferences) { GetSubstanceTexturesFromMaterial(s, mat); } } else { Debug.LogWarning("<color=red>SBS:</color>\n" + "Not a Material"); } } } break; } }
/* * ----------------------- * UpdateDrag() * ----------------------- */ void UpdateDrag(Event e) { CustomDragData dragData = DragAndDrop.GetGenericData(dragDropIdentifier) as CustomDragData; if (dragData == null) { return; } int groupIndex = FindGroupIndex(e); switch (e.type) { case EventType.DragUpdated: if ((groupIndex >= 0) && (groupIndex != selectedGroup)) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } e.Use(); break; case EventType.Repaint: if ((DragAndDrop.visualMode == DragAndDropVisualMode.None) || (DragAndDrop.visualMode == DragAndDropVisualMode.Rejected)) { break; } if (groupIndex >= 0 && groupIndex < groups.size) { EditorGUI.DrawRect(groups[groupIndex].rect, new Color(0f, 1f, 0f, 0.1f)); } break; case EventType.DragPerform: DragAndDrop.AcceptDrag(); // queue the sound FX move QueueSoundFXMove(dragData.originalGroupIndex, dragData.originalIndex, groupIndex); e.Use(); break; case EventType.MouseUp: // in case MouseDrag never occurred: DragAndDrop.PrepareStartDrag(); break; } }
public override void DrawItem(Rect position, int index) { LudiqGUI.Inspector(metadata[index], position, GUIContent.none); var item = this[index]; var controlID = GUIUtility.GetControlID(FocusType.Passive); switch (Event.current.GetTypeForControl(controlID)) { case EventType.MouseDown: // Exclude delete button from draggable position var draggablePosition = ReorderableListGUI.CurrentItemTotalPosition; draggablePosition.xMax = position.xMax + 2; if (Event.current.button == (int)MouseButton.Left && draggablePosition.Contains(Event.current.mousePosition)) { selectedList = this; selectedItem = item; if (alwaysDragAndDrop || Event.current.alt) { GUIUtility.hotControl = controlID; mouseDragStartPosition = Event.current.mousePosition; Event.current.Use(); } } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; if (Vector2.Distance(mouseDragStartPosition, Event.current.mousePosition) >= MouseDragThreshold) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityObject[0]; DragAndDrop.paths = new string[0]; DragAndDrop.SetGenericData(DraggedListItem.TypeName, new DraggedListItem(this, index, item)); DragAndDrop.StartDrag(metadata.path); } Event.current.Use(); } break; } }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); var ids = SortItemIDsInRowOrder(args.draggedItemIDs); var items = new List <object>(ids.Count); items.AddRange(ids.Select(Model.FindByInstanceId).Where(obj => obj != null)); var title = items.Count > 1 ? "<Multiple>" : (items[0] as INamed)?.Name ?? "<Item>"; UTinyDragAndDrop.ObjectReferences = items.ToArray(); UTinyDragAndDrop.StartDrag(title); }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); bool isMultiDrag = args.draggedItemIDs.Count > 1; if (isMultiDrag) { } else { DragAndDrop.SetGenericData("MissionEditor_Drag", SortItemIDsInRowOrder(args.draggedItemIDs)[0]); } DragAndDrop.StartDrag("MissionEditor"); }
void OnGUI() { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("<<", GUILayout.Width(50.0f))) { _Prev(); } if (GUILayout.Button("...", GUILayout.Width(50.0f))) { m_PopupWindow = new HistoryWindow(this); PopupWindow.Show(histRect, m_PopupWindow); } if (Event.current.type == EventType.Repaint) { histRect = GUILayoutUtility.GetLastRect(); } if (GUILayout.Button(">>", GUILayout.Width(50.0f))) { _Next(); } // Ping + drag done as label as drag seems to not work with buttons? GUILayout.Label("\u2299", GUILayout.Width(20.0f)); var rect = GUILayoutUtility.GetLastRect(); var cev = Event.current; var mousePos = cev.mousePosition; var o = Selection.activeObject; if (rect.Contains(mousePos) && o != null) { var mouseStartDrag = false; var mouseClick = false; mouseStartDrag = (cev.type == EventType.MouseDrag) && cev.button == 0; mouseClick = (cev.type == EventType.MouseUp) && cev.button == 0 && cev.clickCount == 1; if (mouseStartDrag) { DragAndDrop.PrepareStartDrag(); DragAndDrop.StartDrag(o.name); DragAndDrop.objectReferences = new UnityEngine.Object[] { o }; Event.current.Use(); } else if (mouseClick) { EditorGUIUtility.PingObject(o); Event.current.Use(); } } EditorGUILayout.EndHorizontal(); }
public override void OnGUI() { if (this.button == null) { this.button = new GUIStyle(GUI.skin.button); } float w = this.button.CalcSize(this.content).x; if (this.image == null) { this.button.padding.left = GUI.skin.button.padding.left; } else { this.button.padding.left = (int)this.hub.height; w += 12F; // Remove texture width, because Button calculates using the whole height. } Rect r = GUILayoutUtility.GetRect(w, this.hub.height, GUI.skin.button); if (Event.current.type == EventType.MouseDrag && Utility.position2D != Vector2.zero && DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null && (Utility.position2D - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance) { Utility.position2D = Vector2.zero; DragAndDrop.StartDrag("Drag Object"); Event.current.Use(); } else if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true) { NGEditorGUILayout.PingObject(asset); Utility.position2D = Event.current.mousePosition; DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new Object[] { this.asset }; DragAndDrop.SetGenericData(Utility.DragObjectDataName, 1); } GUI.Button(r, this.content, this.button); if (this.image != null) { r = GUILayoutUtility.GetLastRect(); r.x += 4F; r.width = r.height; GUI.DrawTexture(r, this.image); } }
void showClassifiedSprite(Sprite sprite, float fWidth, bool bImgOnly) { var evt = Event.current; GUILayoutOption wOption = GUILayout.Width(fWidth), hOption = GUILayout.Height(bImgOnly ? fWidth : (fWidth - 2 * EditorGUIUtility.singleLineHeight)); using (new EditorGUILayout.VerticalScope(wOption)) { Rect ImgRT = EditorGUILayout.GetControlRect(wOption, hOption); if (SelectedSprites.Contains(sprite)) { EditorGUI.DrawRect(ImgRT, Color.gray); } CustomEditorGUI.DrawSprite(ImgRT, sprite, Color.clear, true, true); if (!bImgOnly) { EditorGUILayout.ObjectField(sprite, typeof(Sprite), allowSceneObjects: false, options: wOption); if (SpriteAtlasDic.ContainsKey(sprite)) { AtlasField(SpriteAtlasDic[sprite], false); } } if (ImgRT.Contains(evt.mousePosition)) { if (evt.type == EventType.MouseUp || evt.type == EventType.MouseDrag) { if (!SelectedSprites.Contains(sprite)) { SelectedSprites.Add(sprite); } else if (evt.type == EventType.MouseUp) { SelectedSprites.Remove(sprite); } if (evt.type == EventType.MouseDrag) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = SelectedSprites.ToArray(); DragAndDrop.StartDrag("Dragging title"); } Event.current.Use(); } } } }
/// <summary> /// Creates the DragAndDrop object's references, and begins the drag operation. /// </summary> /// <param name="forgelightGame">The forgelight game containing "actor"</param> /// <param name="actor">The selected actor</param> private void BeginDrag(ForgelightGame forgelightGame, Adr actor) { ActorDefinition actorDefinition = new ActorDefinition { forgelightGame = forgelightGame, actorDefinition = actor }; DragAndDrop.objectReferences = new Object[0]; DragAndDrop.PrepareStartDrag(); DragAndDrop.SetGenericData("ActorDefinition", actorDefinition); DragAndDrop.StartDrag("ActorDrag"); DragAndDrop.visualMode = DragAndDropVisualMode.Copy; }
protected override void SetupDragAndDrop(SetupDragAndDropArgs args) { DragAndDrop.PrepareStartDrag(); var ids = SortItemIDsInRowOrder(args.draggedItemIDs); var items = new List <UnityEngine.Object>(ids.Count); items.AddRange(ids.Select(EditorUtility.InstanceIDToObject).Where(obj => obj != null)); DragAndDrop.objectReferences = items.ToArray(); var title = items.Count > 1 ? "<Multiple>" : items[0].name; DragAndDrop.StartDrag(title); }