Trying to render ScriptedImporter with ToolboxEditor
Closed this issue · 5 comments
Hi,
I am trying to render ScriptedImporter with ToolboxEditor, but not found a way.
So I copy most code of ToolboxEditor, but ToolboxEditorGui.DrawToolboxProperty(property)
seems doesn't draw anything in this case.
Any sugguestions?
Hello,
it's probably related to how ScriptedImporterEditor & AssetImporterEditor are responsible for drawing custom SerializedObjects. It's my first guess but you need to mimic the OnInspectorGUI method.
So basically:
public override sealed void OnInspectorGUI()
{
try
{
OnBeginToolboxEditor?.Invoke(this);
DrawCustomInspector(serializedObject);
if (extraDataType != null)
{
DrawCustomInspector(extraDataSerializedObject);
}
ApplyRevertGUI();
}
catch (Exception)
{
OnBreakToolboxEditor?.Invoke(this);
throw;
}
finally
{
OnCloseToolboxEditor?.Invoke(this);
}
}
You need to refactor DrawCustomInspector a bit because currently, this method is using the serializedObject field instead of an argument. I can look at it in a few days.
@arimger thanks for your reply.
This is my code about DrawCustomInspector, it's works with EditorGUILayout.PropertyField(property)
but nothing drawing on inspector with ToolboxEditorGui.DrawToolboxProperty(property)
public virtual void DrawCustomInspector()
{
if (true) // ToolboxDrawerModule.ToolboxDrawersAllowed)
{
serializedObject.Update();
var property = serializedObject.GetIterator();
while (property.NextVisible(enterChildren: false))
{
EditorGUILayout.PropertyField(property); // works
// ToolboxEditorGui.DrawToolboxProperty(property); // no fields drawing on inspector
}
serializedObject.ApplyModifiedProperties();
return;
}
}
Do you get any warnings?
I'm currently working on a solution, here is PR where everything works just fine: #60
I need to test it a bit, everything should be available in the next release.
Good job, I will try the PR or the next release.
Warning in prev version:
[Editor Toolbox] Do not use Toolbox-related drawers outside ToolboxEditor.
Tried the PR, and it works.
Thank you very much.