sbox-issues icon indicating copy to clipboard operation
sbox-issues copied to clipboard

GameResources and GameObjectSystems are loaded multiple times while opening a project.

Open badandbest opened this issue 1 year ago • 0 comments

Describe the bug

Game resources and game object systems load multiple times when you are opening a project.

To Reproduce

  1. Create a GameObjectSystem and GameResource

    public class MyGameSystem : GameObjectSystem
    {
        public MyGameSystem( Scene scene ) : base( scene )
        {
                Listen( Stage.FinishUpdate, 10, DoSomething, "DoingSomething" );
        }
    
        void DoSomething()
        {
    	    Log.Info( $"Did something!" );
    
    	    // Only run once.
    	    Dispose();
        }
    }
    
    [GameResource("My Game Resource", "test", "A game resource for testing.")]
    public class MyGameResource : GameResource
    {
        protected override void PostLoad()
        {
    	    Log.Info( $"Loaded {this}" );
        }
    }
    
  2. Open your project image

  3. They are loaded/created twice. image

  4. Note that this is before I clicked play on the scene.

Expected behavior

A game resource should only be loaded once.

A game object system should only be created once per scene.

Media/Files

Log.log

Project.zip

Additional context

No response

badandbest avatar Apr 28 '24 22:04 badandbest