- Home /
Detect Mouse Up In Edit Mode
How can I determine if the left mouse button is not being pressed in a script that executes in edit mode?
Answer by Phedg1 · Nov 22, 2015 at 08:09 AM
It took a while to find this because I did not know what to Google.
using UnityEditor;
[CustomEditor(typeof(anchorTool))]
class anchorToolEditor : Editor {
void OnSceneGUI() {
if (Event.current.type == EventType.MouseUp && Event.current.button == 0) {
anchorTool myTarget = (anchorTool)target;
}
}
}
Import UnityEditor and set the script type to Editor, this will allow OnSceneGUI to run in edit mode. [CustomEditor(typeof(anchorTool))] will only run this script when an object with the script "anchorTool" attached is selected and myTarget will be the instance of the "anchorTool" script that is attached to the currently selected object.
This script must be in a folder named "Editor" in the root of your "Assets" directory.
Your answer
Follow this Question
Related Questions
Can't shoot towards mouse click point 1 Answer
Is There An OnMouseStop? 0 Answers
Smaller object jumps around bigger when dragged by mouse cursor 0 Answers
How to properly convert mouse pos to world pos 1 Answer
C# move main camra via mouse position on boarders around screen script for RTS Game 0 Answers