Not a Bug

2.0.0a6 Scene and Singleton scope classes fail to load.

NeedsLoomis 1 year ago updated by Lazlo Bonin (Lead Developer) 1 year ago 3

It appears that when not directly referenced by a component in the scene, Scene/Singleton Class definitions don't instantiate themselves.

In my case, I have a Scene Class that's (in theory) always doing some calculations and applying the results to various Asset Classes.  Even though components in my scene use those assets, the scene won't instantiate itself, and thus it wont do its calculations.

My current work around is to send a shared event to everything on load, forcing them to spawn.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
.NET 4.x
Bolt 2

I will add that if you have a 'component' class and switch it to a 'singleton' class, Bolt removes the reference to the Class def on the Class Component script, however, it still acts like and responds like it is a 'component' class until you delete the game object the component script is attached to. Then it fully switches to the behavior of a singleton class.

Hi CSmith,

That sounds like a separate issue. Please create a new thread with reproduction steps!

Not a Bug

Hi NeedsLoomis,

That is by design. You might want to create Scene classes that don't spawn in every scene, for example.

However you can pre-instantiate a scene class in your scene:

  1. GameObject > Bolt > Scene Class Container
  2. Add a Class Component
  3. Choose your scene class definition

The singleton class scope design might change to be instantiated in the scene too in the next version. I'll take this into consideration when implementing that feature.