I'm implementing a custom level editor and I need to make sure that when I get mouseDown event on my terrain, current object (RoadObject) doesn't deselect. I need to add many markers to the terrain to implement a road system.
How can I achieve this?
I'm implementing a custom level editor and I need to make sure that when I get mouseDown event on my terrain, current object (RoadObject) doesn't deselect. I need to add many markers to the terrain to implement a road system.
How can I achieve this?
Yay, I found the solution! :)
In case if somebody stumbles upon the same problem, here's what has to be done:
@CustomEditor (MyScript)
class MyEditor extends Editor {
function OnSceneGUI()
{
if (currentEvent.shift && currentEvent.type == EventType.mouseDown)
{
//Do your thing
}
//Return focus back to THIS GameObject to be able to continue processing events
//This is very important, this part should be outside of the previous condition!!!
Selection.activeGameObject = target.transform.gameObject;
}
}
This code will make sure that current object will not deselect even if you press inside the editor. Should be very helpful for any custom visual editor.
Hope this will save somebody a whole day of his life. :)