Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request : Odin Inspector compatibility for New Fields #77

Closed
GhatSmith opened this issue May 22, 2023 · 10 comments
Closed

Request : Odin Inspector compatibility for New Fields #77

GhatSmith opened this issue May 22, 2023 · 10 comments
Labels
nice-to-have Not critical to core functionality

Comments

@GhatSmith
Copy link

Right now, when the project is using Odin Inspector, you have to switch inspector to Debug mode to see the [FSR] Dynamically Added Fields. Would be great if there was a direct compatibility with Odin Inspector, without having to use debug mode.

@handzlikchris
Copy link
Owner

I've got a feeling Odin will replace Default inspector, FSR is hooking into it via FastScriptReload.Editor.NewFields.NewFieldsRendererDefaultEditorPatch.NewFieldsRendererDefaultEditorPatch

Probably as simple as changing Patch target from default inspector to Odin one.

If you know which one would that be then I'll be simpler to put in

@handzlikchris handzlikchris added the nice-to-have Not critical to core functionality label May 23, 2023
@GhatSmith
Copy link
Author

I made this fix, and it seems to work. Feel free to include it officially!
Caution: I'm using Odin v2, so I've not tested on the last Odin version (v3), but it should work I think.

Code at the end of the NewFieldsRendererDefaultEditorPatch static constructor:

#if ODIN_INSPECTOR
                var renderAdditionalFieldsDrawOdinInspectorPostfix = AccessTools.Method(typeof(NewFieldsRendererDefaultEditorPatch), nameof(DrawOdinInspector));
                var customOdinEditorRenderingMethod = AccessTools.Method("Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector");
                harmony.Patch(customOdinEditorRenderingMethod, postfix: new HarmonyMethod(renderAdditionalFieldsDrawOdinInspectorPostfix));
#endif

Method added to the class: NewFieldsRendererDefaultEditorPatch

private static void DrawOdinInspector(UnityEditor.Editor __instance)
{
    RenderNewlyAddedFields(__instance);
}

@handzlikchris
Copy link
Owner

nice one, thanks - if you could PR - that'd be great. Otherwise I'll try to put it in with other changes

@GhatSmith
Copy link
Author

Included in my pull request.

@builder-main
Copy link

@GhatSmith #80 (comment)
Could I have your feedback on this ? Thanks for trying to add this, I'm on Odin 3 however.

@GhatSmith
Copy link
Author

GhatSmith commented Oct 31, 2023

@GhatSmith #80 (comment) Could I have your feedback on this ? Thanks for trying to add this, I'm on Odin 3 however.

Just had a look, my bad I forgot to add something in my initial pull request...
@handzlikchris could you add the missing DrawOdinInspector method inside your NewFieldsRendererDefaultEditorPatch class please, so the nameof is working properly.

#if ODIN_INSPECTOR
        private static void DrawOdinInspector(UnityEditor.Editor __instance)
        {
            RenderNewlyAddedFields(__instance);
        }
#endif

By the way I tested with latest Odin version (v3.1.14.3) and it was working (with the fix mentioned above of course) .

@handzlikchris
Copy link
Owner

thanks - that's added

@nick-s5
Copy link

nick-s5 commented Dec 13, 2023

The DrawOdinInspector method is missing in the current Asset Store version

@OikoumE
Copy link

OikoumE commented Mar 11, 2024

just installed fast script reload 1.6.1 on unity 2022.3.17f1 and im getting this error:

Assets\FastScriptReload\Scripts\Editor\NewFields\NewFieldsRendererDefaultEditorPatch.cs(34,141): error CS0103: The name 'DrawOdinInspector' does not exist in the current context

image

even after installing Odin (3.2.1.0 inspector+serializer) error persists

@handzlikchris
Copy link
Owner

you can try pull github version - tere's was an update that addesses it
260169c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nice-to-have Not critical to core functionality
Projects
Status: Done (and released)
Development

No branches or pull requests

5 participants