- Home /
How do I get the default scene GUI for a CustomEditor for RectTransform?
I am trying to extend the default RectTransform to add some buttons with simple functionalities. I know how to draw the default inspector to extend the RectTransform like this: Editor defaultEditor;
void OnEnable(){
defaultEditor = Editor.CreateEditor(targets, Type.GetType("UnityEditor.RectTransformEditor, UnityEditor"));
}
public override void OnInspectorGUI()
{
defaultEditor.OnInspectorGUI();
}
But I am not able to draw the default gizmos in the scene view, i.e. the anchors, which should also be intractable: (the picture on the left is with the extension, the two pictures on the right are without).
is there a way to draw the default scene gizmos (I am assuming they are gizmos) in the same ways we are drawing the default inspector?
bitmap.png
(91.8 kB)
Comment
Best Answer
Answer by RedHillbilly · Mar 10, 2020 at 05:00 PM
Finally found the answer here: https://forum.unity.com/threads/recttransform-custom-editor-ontop-of-unity-recttransform-custom-editor.455925/
private void OnSceneGUI() {
MethodInfo onSceneGUI_Method = defaultEditor.GetType().GetMethod("OnSceneGUI", BindingFlags.NonPublic | BindingFlags.Instance);
onSceneGUI_Method.Invoke(defaultEditor, null);
}