What threads are used in a scene?

I’m designing the general architecture of my game, using c#, and I’ve implemented a singleton pattern, which I hope will facilitate communication between some of my game objects.

My Question, if I add the same script to a bunch of GameObjects, and the script calls functions on the singleton, would the singleton need to be thread safe? That is, all the GameObjects would then have similar functionality, all calling the same function, the same variables in that function, would I need to use lock() (or something similar) when changing values in the singleton from the scripted GameObjects?

Unity is not “thread safe” in the sense that it doesn’t actually let you work with its objects from different threads. If you try, it will throw up an error.

In your case, every GameObject will be on the same thread and it’s safe to access your singleton from any other GameOject. You don’t need to lock anything, because no Unity stuff, no Update()s or other events will run concurrently. Unless you make you own threads, everything will happen sequentially (although the order is not guaranteed).

See also: This answer.