Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Experiencing a strange crash with globalgamemanagers

Discussion in 'Windows' started by JustinKovacich, Aug 22, 2023.

  1. JustinKovacich

    JustinKovacich

    Joined:
    Jun 10, 2020
    Posts:
    10
    We have built our project into a windows executable. It is very similar to a previous build, some gitignore, meta and DLL files got shifted around/modified. The new build fails, the previous build works. When we do a diff, we see that globalgamemanagers has changed. Replacing the new globalgamemanagers for the old globalgamemanagers actually causes the application to load (and appears to work well).

    Any idea what could be triggering that and ways to work around it?
     
  2. JustinKovacich

    JustinKovacich

    Joined:
    Jun 10, 2020
    Posts:
    10
    Ok. We've identified that the problem stems from us using .gitignore and deleting our old meta files. We need our DLLs to load on startup by default.

    Our workflow is a little unique, in that we don't commit the binaries to our plugins folder. We run a script that does that for us. We have some application logic written in native code that can change and its a big headache when we have conflicts between these files, so we just let the individual engineers run the code to generate the files when they need.

    The issue is deleting those files means the .meta files, which dictate whether or not those files should load by default or not, also get deleted, because Unity cleans them up. Those meta files have a setting tweaked, we want to load our plugins at startup by default. Is there a way to configure that?

    I see in https://docs.unity3d.com/Manual/PluginInspector.html it calls out that we can implement `UnityPluginLoad` to possibly configure it to load automagically, but we should assume any of the plugins loaded by Unity are multi-purpose, and we can't implement those sorts of things at the DLL level.
     
  3. JustinKovacich

    JustinKovacich

    Joined:
    Jun 10, 2020
    Posts:
    10
    Should anyone run into anything similar in the future, this code was where I ended up, and it needs to live in the Editor subfolder, it doesn't get attached to any game objects/live in the unity hierarchy.

    Code (CSharp):
    1. public class PluginImportPostprocessor : AssetPostprocessor
    2.     {
    3.         // This method is called whenever assets are imported, deleted, or moved.
    4.         private static void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths )
    5.         {
    6.             foreach ( string str in importedAssets )
    7.             {
    8.                 if ( str.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || str.EndsWith(".so", StringComparison.OrdinalIgnoreCase) )
    9.                 {
    10.                     PluginImporter pluginImporter = AssetImporter.GetAtPath(str) as PluginImporter;
    11.  
    12.                     if ( pluginImporter != null  && pluginImporter.isNativePlugin )
    13.                     {
    14.                         pluginImporter.isPreloaded = true;
    15.                         pluginImporter.SaveAndReimport();
    16.                     }
    17.                 }
    18.             }
    19.         }
    20.     }