Hello,
I’ve ran into this weird bug that I just can’t fix it.
I run the game in editor and everything works just fine. but when I run the development build in windows or on my Android device the game freezes and it doesn’t show any error. Tried to catch the error with try and catch and LogCat and there is no error.
I manually debugged the code and got to this method in one specific script. When I run the built version the last Debug.Log console massage I get is the "DEBUG 3". Even the Debug.Log(craftedItems.Count); shows 20 which is correct.
On the other hand I have the same exact code with GetTypes and create them with CreateInstance for some other purpose and there is nothing wrong with them and they work fine.
I didn’t create any Assembly Definition and nothing special. I use Unity-2023-1.5f1 version!
Edit: With Preserve nothing changes. Even I set the Managed Scripting Level to Disable so unity doesnt delete any lines of code I still have the problem!
Second Edit: Updating unity editor to 2023.2.16f1 didn’t solve the problem.
Third Edit: The problem is with the new BluePrintItem(). Seems that I can not create any instance of BluePrintItem. on calling new BluePrintItem the build version gets crashed without any error log. HELP ME PLEASE ![]()
private void InitTierCraftedList()
{
Debug.Log("DEBUG 1");
List<Type> craftedItems = Assembly.GetAssembly(typeof(BluePrintItem)).GetTypes().ToList().
Where(Thetype => Thetype.IsClass &&
!Thetype.IsAbstract && Thetype.IsSubclassOf(typeof(BluePrintItem))).ToList();
Debug.Log("DEBUG 2");
Debug.Log(craftedItems.Count);
foreach (var item in craftedItems)
{
Debug.Log("DEBUG 3");
BluePrintItem target = (BluePrintItem)Activator.CreateInstance(item);
int highestTier = 0;
Debug.Log("DEBUG 342");
foreach (var material in target.materialsList)
{
Debug.Log("DEBUG 4");
if (material.GetItemTier() > highestTier)
{
highestTier = material.GetItemTier();
Debug.Log("DEBUG 5");
}
}
Debug.Log("DEBUG 6");
switch (highestTier)
{
case 1: firstTierItems.Add(target.CraftedItemReference()); break;
case 2: secondTierItems.Add(target.CraftedItemReference()); break;
case 3: thirdTierItems.Add(target.CraftedItemReference()); break;
case 4: forthTierItems.Add(target.CraftedItemReference()); break;
default: Debug.LogWarning("CHECK HERE ASAP"); break;
}
}
Debug.Log("DEBUG 7");
craftedItems.Clear();
craftedItems = Assembly.GetAssembly(typeof(MaterialItem))
.GetTypes().Where(TheType => TheType.IsClass && !TheType.IsAbstract && TheType.IsSubclassOf(typeof(MaterialItem))).ToList();
Debug.Log("DEBUG 8");
foreach (var item in craftedItems)
{
Debug.Log("DEBUG 9");
MaterialItem target = (MaterialItem)Activator.CreateInstance(item);
Debug.Log("DEBUG 10");
switch (target.GetItemTier())
{
case 1: firstTierItems.Add(target); break;
case 2: secondTierItems.Add(target); break;
case 3: thirdTierItems.Add(target); break;
case 4: forthTierItems.Add(target); break;
default: Debug.LogWarning("CHECK HERE ASAP"); break;
}
//firstTierItems.Add(target);
Debug.Log("DEBUG 11");
}
craftedItems.Clear();
craftedItems = Assembly.GetAssembly(typeof(Herb))
.GetTypes().Where(TheType => TheType.IsClass && !TheType.IsAbstract && TheType.IsSubclassOf(typeof(Herb))).ToList();
Debug.Log("DEBUG 12");
foreach (var item in craftedItems)
{
Herb target = (Herb)Activator.CreateInstance(item);
switch (target.GetHerbTier())
{
case 1: firstTierItems.Add(target); break;
case 2: secondTierItems.Add(target); break;
case 3: thirdTierItems.Add(target); break;
case 4: forthTierItems.Add(target); break;
default: Debug.LogWarning("CHECK HERE ASAP"); break;
}
//firstTierItems.Add(target);
}
Debug.Log("DEBUG 13");
craftedItems.Clear();
craftedItems = Assembly.GetAssembly(typeof(Seed))
.GetTypes().Where(TheType => TheType.IsClass && !TheType.IsAbstract && TheType.IsSubclassOf(typeof(Seed))).ToList();
Debug.Log("DEBUG 14");
foreach (var item in craftedItems)
{
Seed target = (Seed)Activator.CreateInstance(item);
switch (target.GetSeedTier())
{
case 1: firstTierItems.Add(target); break;
case 2: secondTierItems.Add(target); break;
case 3: thirdTierItems.Add(target); break;
case 4: forthTierItems.Add(target); break;
default: Debug.LogWarning("CHECK HERE ASAP"); break;
}
//firstTierItems.Add(Target);
Debug.Log("DEBUG 15");
}
}
Have you tried wrapping your code in a try catch and logging any exception that might be thrown? Have you checked the log file of your standalone build? What exactly happens after your log 3. What exactly are those "BluePrintItem" derived classes? Are they pure C# classes? We can't do the debugging for you. We don't have your project or code.
– Bunny83Just posted that what was the problem. I tried all of those that you mentioned. Even try catch didn't find anything. Still thanks for the help mate <3
– unity_84F316212DF5E2C6B65B