How to make drag-drop detecting Editor script?
Hi, I'm wanting to detect when an object or objectS are drag/dropped onto another object to reparent them. I'd like to pop up a UI to select 'keep local transforms?' so that the objects will reposition themselves relative to the object onto which they are dropped, rather than recompute position to retain their world positions. Do I use a CustomEditor? Would that be for type Transform? Do I use OnSceneGUI? I ask cuz what I have is not being called:
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(Transform))]
public class Reparent : Editor {
private GameObject draggedObj;
public void OnSceneGUI()
{
if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform) // gets here....
{
DragAndDrop.visualMode = DragAndDropVisualMode.Copy; // show a drag-add icon on the mouse cursor EXCEPT IT NEVER GETS HERE
Your answer
Follow this Question
Related Questions
ReorderableList (or similar) for UIElements 0 Answers
Undo Redo Custom Editor Error ("Assertion failed on expression: '!GetUndoManager().IsProcessing()'") 0 Answers
Multiple custom editors for the same type 0 Answers
Custom editor for a global list of variables, similar to Tags and Layers. 0 Answers
Adding custom edits to scene window 0 Answers