I have a custom editor script where i am clicking in the scene view to select objects. But when i click I lose focus of the editor from inspector so i no longer have scene interactions, how do i stop this from happening? I tried the following:
if (Event.current.type == EventType.MouseUp)
{
if (Event.current.button == 0)
Event.current.Use();
}
This of course did absolutely nothing so does any one know how to stop the inspector focus being losed when clicking in the scene window?
Shouldn’t need to do that. There has been tools out there that lets you click in scene and doesn’t lose focus on the inspector without locking it. Plus that would be tedious to keep doing.
If, in some way, you prevent selecting other objects in the scene, how would you ever deselect your initially selected object? I assume you should be looking into the OnSceneGUI of a custom editor (or custom window).
It would be even better if you could describe what you are specifically doing. That might help provide a more concrete answer.
In order for your snippet to keep your inspector in focus, you’d need to set the Selection.activeGameObject back to your initial object. But that doesn’t sound like what you want to do?
If you need to select other objects in the scene view, you might be better off creating an editor window.
Another option is to open a separate inspector tab and lock it as per the suggestion above.
But its not a gameobject its a scriptable object. I don’t need to select anything in scene view, just click in it to get world point on the XZ plane from scene camera via raycast.
I’ve attempted this before for a ‘Scene-picker’ type tool but couldn’t figure it out myself. I know I’ve seen tools out there that do it, so honestly why not take a look at our source code and see what they do?
Well, we need to see a bit more code to be sure of the issue. The right lines in the wrong place won’t do anything.
From memory, the steps are:
Implement an OnSceneGUI method in your custom Inspector. I believe that this is how things such as the Terrain component’s custom editor works, and that definitely overrides the default Scene view input behaviours.