I have a game object that contains List in it. I assigned the sprites by drag&drop in the Unity Editor.
I have also this piece of code that tries to read the sprites data and compare the name:
private PlayerProfile.CollectibleAddOn FindByName(string name)
{
Debug.LogFormat("Are there addOns? " + StaticGameSettings.Profile.AddOns.Count);
for (int i = 0; i < StaticGameSettings.Profile.AddOns.Count; i++)
{
var addOn = StaticGameSettings.Profile.AddOns[i];
Debug.LogFormat("Comparing: " + name + " with " + addOn.Sprite.name);
if (addOn.Sprite.name == name) return addOn;
}
return null;
//return StaticGameSettings.Profile.AddOns.FirstOrDefault(a => a.Sprite.name == name);
}
If I build with Development Build toggle off, everything works perfectly fine.
If I build with Development Build toggle on, the above function will print the first line with Count=27, and it will never print the second line, where I’m fetching addOn.Sprite.name. If instead I fetch any other property assigned to the addOn class (e.g. addOn.equipped which is a boolean) it prints the value correctly, and I did verify that addOn.Sprite is not a null.
There are no logs in the console that would suggest any sort of exception being thrown, but that function simply stops executing the moment I try to access properties of Sprite. Again - without Development Build everything works properly and the comparison is successful.
At first I blamed LINQ (the commented out part), but it looks like it’s not related to this. I’m using Unity 2021.3.14f1. Any help in debugging this is much appreciated!
I need the development build so that I can run profiler on my game…