Recently, I begun getting the following error "
get_isPlaying is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'ObjectSpawn'.
See "Script Serialization" page in the Unity Manual for further details.
Chronos.Singleton`1:get_instance() (at Assets/Chronos/Source/Utilities/Singleton.cs:25)
ObjectSpawn:.ctor() (at Assets/_Scripts/ObjectSpawn.cs:18)
" I was playing around with a script that was 100% fine before and it started showing up. Despite the errors being seemingly detailed. I am not able to find out why it's occurring as it doesnt break / stop the game but shows up and id like to handle it.
It points to the following line with isPlaying.
public static T instance
T instances = FindObjectsOfType<T>();
And please find the entirely of my Object Spawn code below
public class ObjectSpawn : BaseBehaviour //MonoBehaviour
public float minTime = 3f;
public float maxTime = 9f;
public float minX = -65.5f;
public float maxX = -5.5f;
public float topY = -5.5f;
public float z = 0.0f;
public int count = 50;
public GameObject prefab;
public bool doSpawn = true;
Clock clock = Timekeeper.instance.Clock("MovingOneWayPlatforms");
while (doSpawn && count > 0 )
Renderer renderer = GetComponent<Renderer>();
float min = renderer.bounds.min.x;
float max = renderer.bounds.max.x;
Vector3 v12 = new Vector3(Random.Range(minX, maxX), this.gameObject.transform.position.y, 0f);
prefab = Instantiate(prefab, v12, Random.rotation);
// yield return new WaitForSeconds(Random.Range(minTime, maxTime));
yield return time.WaitForSeconds(Random.Range(minTime, maxTime));
Customer support service by UserEcho