2022.02.0b9 Asset has disappeared while building player to 'globalgamemanagers.assets'

We were seeing this issue on our build machines for MacOS and Android builds. The only ones that worked were Windows and iOS. iOS runs on the same build agent as MacOS, and all the Android ones run on the same agent as Windows. It seemed to be the same asset that goes missing on all builds.

I opened this prefab and forced a resave of the asset. As we’d updated the version of Unity, there were some meta changes to the file that needed to be committed to source control. After that, the builds all completed as expected.

Probably my case is atypical, but maybe those who will read this many threads with disappearing assets during build, will see something useful in it.
So, I’m in Windows with Editor 2021.2.4 (so old, because I need to fit in a 20 MB instant for Google Play), build accordingly under Android. Not many changes relative to the previous commit - int in the script of one of the prefabs, a few scripts that couldn’t affect anything. I get a stable error

Asset has disappeared while building player to '00000000000000000000000000000000' - path ''

with changing instancedID. Nothing useful in Editor.log. I start reading about possible causes. I delete Library, to no avail. I investigate the build report via Project Auditor, which extends the search to globalgamemanagers.assets. I do Clean Build from Build Settings, the error changes to

Asset has disappeared while building player to 'resources.assets' - path ''

which narrows it down a bit. I start checking prefabs in Resources folder and find one with serialized reference to ScriptableObject (with fonts), which should not be there. The fonts have been moved to AssetBundle to be loaded later. The code in this place looks like this

#if ENABLE_TMP
    public List<TMP_FontAsset> fonts;
#else
    AssetBundle bundleFonts;
    public FontRepository fonts;
#endif

Because the field name was the same, Rider helpfully added a FormerlySerializedAs(), which I removed as unnecessary and automatically attached ScriptableObject FontRepository to the prefab with this script, which escaped my attention. Eventually my problem was solved by adding [NonSerialized] to the

public FontRepository fonts;

End of story.

I just ran into this SAME PROBLEM, with the SAME ERROR, using 2022.3.19f
[SOLUTION] Restart Unity, did a build, and the build completed with NO ERRORS. This is starting to be like Microsoft Windows, where they do an update, and Windows is not working correctly, because someone in the Update Team, working on the UPDATE, forgot to take out something he was testing.

Just got this error in 2022.3.22f

Good News: It looks like in the 2023 Version the bug is gone. I updated some days ago, did several compiles, and never got any of these annoying compile issues!!! (now at 2023.2.18f1)

But it looks there are some other issues, i got GPU crashes and the editor looks a bit more unstable, also 3-4 other bugs comming up. But the most annoying bug mentioned here is gone :slight_smile:

Thread locked. The beta section for 2022.2 is now closed. Please start a new thread if you wish to continue the discussion.

Awesome… The thread started at the beta start of the beta version, and now after over a year no further investigation, multiple threads about that topic, open support tickets and lots of people with the same issue, the thread was just closed…

Good job…

4 Likes

I found the culprint to this after days of digging. For us, this issue is fixed after turning off “Show Unity Logo” in Project Settings → Player → Splash Image → Show Unity Logo

Before turning “Show Unity Logo” off, I had to restart unity multiple times before getting a build to finish.

The way I figured this out was by tracking the instanceID listed in the error message. I created an empty scene, added only 1 gameobject with 1 component, which is a script that prints every single InstanceID and it’s associated object. I then made a build which ONLY has this one testscene.

Here is the script I used for that:

using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using UnityEngine;

[ExecuteInEditMode]
public class TheUltimateBugFinder : MonoBehaviour
{
    void Awake()
    {
        // Change the numbers here roughly include your faulty instance id
        for (int i = 0; i < 20000; i++)
        {
            Check(-i);
        }
    }

    private void Check(int id)
    {
#if UNITY_EDITOR
        Object obj = UnityEditor.EditorUtility.InstanceIDToObject(id);
        if (!obj)
            Debug.LogWarning(id + " No object could be found with instance id");
        else
        {
            Debug.Log(id + " Object's name: " + obj.name + "\nToString: " + obj.ToString() 
                + "\nType: " + obj.GetType().ToString());

            // This part is specific to my case, so I can print all properties of the Sprite that caused my build to fail.
            if(obj is Sprite)
            {
                var sprite = obj as Sprite;
                PropertyInfo[] pi = sprite.GetType().GetProperties();
                var print = "";
                foreach (PropertyInfo p in pi)
                {
                    print += p.Name + " : " + p.GetValue(obj) + "\n";
                }
                Debug.Log(print);
            }

        }
#endif
    }
}

In my case, the missing InstanceID turned out to be a Sprite. I then went ahead and printed all the properties of that sprite. This printed the following:

Note the line “texture : Splash Screen Unity Logo (UnityEngine.Texture2D)”. So my build has been failing because something somehow deleted the in-memory copy of the unity splash screen logo? Alright then.

I went straight ahead and turned off the setting for showing the unity splash logo and boom. My build worked flawlessly ever since.

Coming up with the idea of having an empty scene print the first 0-20000 instanceID’s took me about a week to come up with, during which I was trying to randomly exclude the execution of ExecuteInEditMode during builds…

We’re on Unity 2022.3.22f1

Hope this helps any poor soul facing this issue in the future!

1 Like

Thank you for sharing your technique for narrowing down the object that is disappearing!

1 Like