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

ReflectionBaking NullReferenceException #59

Open
joaokucera opened this issue Oct 26, 2022 · 1 comment
Open

ReflectionBaking NullReferenceException #59

joaokucera opened this issue Oct 26, 2022 · 1 comment

Comments

@joaokucera
Copy link

Describe the bug

NullReferenceException: Object reference not set to an instance of an object
Zenject.ReflectionBaking.ReflectionBakingInternalUtil.TryForceUnityFullCompile () (at Packages/com.gamehouse.yggdrasil.client.zenject/OptionalExtras/ReflectionBaking/Unity/ReflectionBakingInternalUtil.cs:72)
Zenject.ReflectionBaking.ZenjectReflectionBakingSettingsEditor.OnInspectorGUI () (at Packages/com.gamehouse.yggdrasil.client.zenject/OptionalExtras/ReflectionBaking/Unity/ZenjectReflectionBakingSettingsEditor.cs:116)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at /Users/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Editor/Inspector/InspectorElement.cs:636)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

To Reproduce
I have added ZenjectReflectionBakingSettings and pressed the checkbox "Is Enabled In Editor".

Expected behavior
No exception and recompile Unity.

Extenject and Unity info (please complete the following information):

  • Zenject version: 9.2.1
  • Unity version: 2021.3.1f1
  • Project's scripting backend [e.g. Mono/IL2CPP]: IL2CPP

Additional context
dirtyAllScriptsMethod variables is null in the method below:

public static void TryForceUnityFullCompile()
{
    Type compInterface = typeof(UnityEditor.Editor).Assembly.GetType(
        "UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface");

    if (compInterface != null)
    {
        var dirtyAllScriptsMethod = compInterface.GetMethod(
            "DirtyAllScripts", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

        dirtyAllScriptsMethod.Invoke(null, null);
    }

    UnityEditor.AssetDatabase.Refresh();
}

Also, I have many asmdef files in my project, would it be an issue?

@WhippetsAintDogs
Copy link

WhippetsAintDogs commented Oct 11, 2023

Prior to Unity 2019.3, the UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface.DirtyAllScripts method existed and was used through reflection to force a recompilation. But now there is a public "preferred" way to do it without using reflection which is UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants