I started having a random error after a unity restart. I think it has something to do with the save system and for now i skipped the " under the hood" section of the save system. also if it matters i have not refactored for the vulnerability yet. below is my error.
when i select it it brings me to line where we instantiate the persistentObject
( the error does not stop me from compiling or playing the game)
using System;
using UnityEngine;
namespace RPG.Core
{
public class PeristentObjectSpawner : MonoBehaviour
{
[SerializeField] GameObject persistentObjectPrefab;
static bool hasSpawned = false;
private void Awake()
{
//i actually kindof hate this solution it feels a race condition risk all to protect against singleton...maybe refactor later
if (hasSpawned) return;
SpawnPersistentObjects();
hasSpawned = true;
}
private void SpawnPersistentObjects()
{
GameObject persistentObject = Instantiate(persistentObjectPrefab);
DontDestroyOnLoad(persistentObject);
}
}
}