- Home /
Keep custom handles always visible in editor
Currently working on a custom editor script, my handles keep hiding when I select an other gameobject which doesn't have the script attached.
The question has already been posted but I couldn't find a proper (complete and well explained) way of solving this. I'm trying to get the solution posted by @whydoidoit to work, but as long as Sceneview is not documented I am still struggling!
Answer by kOnINC · Mar 15, 2018 at 03:31 PM
Well, I got it to work !
Here is the solution, replace your OnSceneGUI() function with CustomOnSceneGUI()
using UnityEditor;
using System;
[CustomEditor(typeof(BaseClass))]
public class BaseClassCustomEditor : Editor {
void OnEnable()
{
SceneView.onSceneGUIDelegate += (SceneView.OnSceneFunc)Delegate.Combine(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(CustomOnSceneGUI));
}
void CustomOnSceneGUI(SceneView sceneview)
{
//Work here !
}
}
THAN$$anonymous$$ YOU SOOOOOOO $$anonymous$$UCH!!
Updated version:
private void OnEnable()
{
SceneView.duringSceneGui += CustomOnSceneGUI;
}
private void CustomOnSceneGUI(SceneView view)
{
//your code here
}
Do you have any solution for showing multiple gameobject handles in the Sceneview ?
Answer by _slash_ · Feb 08, 2021 at 12:23 PM
Thanks, you also need to remove the callback when done:
private void OnEnable()
{
SceneView.duringSceneGui += CustomOnSceneGUI;
}
private void OnDisable()
{
SceneView.duringSceneGui -= CustomOnSceneGUI;
}
private void CustomOnSceneGUI(SceneView view)
{
//your code here
}
This doesn't work for me, everytime I deselect my custom editor, the onDisable
is being called. It just do its default behavior which is hiding when unselected.
Your answer
Follow this Question
Related Questions
Vector2 Editor Visualization 2 Answers
How to show an Editor Window based upon Selection 1 Answer
Style labels in editor window (in scene view) 0 Answers