Unity 2022.3.7f1 LTS. In the editor and play mode, everything works as it should. The build is built without errors and warnings. The build includes one test scene and several game objects in it, as well as in resources. After the build is launched, the “Made with Unity” window appears for a second, after which the client crashes. In a practical way, it was determined that the build crashes, provided that one of the scripts in the scene has a link to the prefab in the resources. If you leave the null field and collect, the scene starts and works. It is necessary to assign a serializable field some value other than null - and hello. I assumed that something was wrong with the packages, reset them to default settings and set the required minimum. It didn’t have any effect. The script with which I associate the possible cause of this obscenity is nothing special, it is a common monobeh for managing a pool of objects. The presence or absence of the pool itself in the script does not affect anything, I also sinned against this. Just in case, the code:
public class RegionsObjectsPoolHandler : ObjectsPoolHandlerBase
{
[SerializeField] Region regionPrefab;
[SerializeField, ReadOnly, Space] protected RegionsObjectsPool pool;
#if UNITY_EDITOR
[SerializeField] MapForm expectedMapForm;
[Button]
void CreateRegionsEditor()
{
var targetCount = expectedMapForm.RegionsCount();
Pool.SpawnObjects(targetCount);
}
#endif
protected override void CreatePoolButton()
{
if (pool != null)
pool.Clear();
pool = new RegionsObjectsPool(regionPrefab);
}
protected override void ClearPoolButton()
{
pool.Clear();
}
public RegionsObjectsPool Pool
{
get
{
if (pool == null)
pool = new RegionsObjectsPool(regionPrefab);
return pool;
}
}
internal Region GetRegion()=>
pool.GetItem();
internal void InsertRegion(Region region)=>
pool.ReturnItem(region);
internal void ReturnRegions(IEnumerable<Region> regions)
{
foreach (var region in regions)
Pool.ReturnItem(region);
}
}
ObjectsPoolHandlerBase:
public abstract class ObjectsPoolHandlerBase : MonoBehaviour
{
[Button(Name = "Create pool")]
protected abstract void CreatePoolButton();
[Button(Name = "Clear pool")]
protected abstract void ClearPoolButton();
}