A very noob question about a console message

So, I’m doing the Junior Programmer thing on Unity Learn and building a very primitive little game on Unity version 2018.4.33f1 as part of it. It’s a sideways thing where player has to dodge flying balls. It runs exactly as intended but now I get the following console message:

InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
UnityEngine.Object.EnsureRunningOnMainThread () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:153)

I think it has something to do with the particle system because before adding those there was no error message. Any advice?
Here the PlayerController code:

 using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
    public float verticalInput;
    public float speed = 10.0f;
    public ParticleSystem EnergyExplosion;
    public ParticleSystem DustExplosion;
  
    // Start is called before the first frame update
    void Start()
    {
    }
    // Update is called once per frame
    void Update()
    {
        verticalInput = Input.GetAxis("Vertical");
        transform.Translate(Vector3.up * verticalInput * Time.deltaTime * speed);
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == 12)
        {
            Debug.Log("GAME OVER!");
            DustExplosion.Play();
            Destroy(gameObject);
        }
        else if (other.gameObject.layer == 11)
        {
            EnergyExplosion.Play();
            Destroy(other.gameObject);
        }
    }
}

Hm. I think I found the answer - it something I’d call a glitch, as people have had it before and apparently it has something to do with the animation window being open, not with an actual error in the code. Anyhow - I have now been tinkering on my game, changed things a lot and this particular error message went as mysteriously as it came. I don’t have this problem anymore. Instead I have other, bigger ones. :smile: But these I leave for another post.

1 Like

Yeah, in these instances, these warnings/errors are coming from the built-in Unity components. You’ll have to get used to seeing them appear in the console, as they’re pretty common.

A key thing to look for in any error messages is the name of the script file. The error you’ve posted states that it’s in the following file:
UnityEngineObject.bindings.cs

As long as you know that this is not one of your scripts, you can usually ignore it (unless it’s from an asset instead).

2 Likes