#Protip: Super fast enter playmode times when working in DOTS

I noticed that not everyone who is using Entities for all simulation code in the game is also enabling fast enter play mode on their projects.

You are wasting valuable time! Fortunately it’s straightforward to fix.

For reference: Enter Playmode on DOTS shooter is ~500ms… And you can have the same on your project today. Without the fast playmode enabled it takes around 5-10 seconds.

Fast enter play-mode in Unity is not the default because most projects are game object based and game object based projects have a tendency to use tons of static variables for state. And doing that by default makes it so that a domain reload is required to reset all the static state before entering playmode.

By design, everything we do in DOTS avoids this pattern. Multiple worlds, per world singletons etc.
They exist so that it becomes trivial to turn on the faster enter play mode option.

This is the recommended setting in a DOTS based project:

If you are making a DOTS based project where all or most simulation code is written with entities or if you simply have no static variables in your project you rely on for persistent state, then you should enable it. I recommend doing this as the first thing when starting a project, so that you force yourself to not create any global static state at any point.

In the future, we have more functionality coming that further improves iteration speed on top of this. But it all requires turning this option on first.

49 Likes

Hi, What about “Unity” hybrid components, like Audio, VFX and others, are they compatible with that feature ?

Yes.

2 Likes

Thx Joachim for reminder. I implemented relevant changes recently, which improved entering play mode greatly for me.

I think this link from a blog, is worth to be referenced here too
https://discussions.unity.com/t/763599

Holy moly thank you! You got any other likely things I forgot that radically make my development experience better like this? (weird question I know but now I am wondering what else I am missing out on…)

@Joachim_Ante_1 Don’t miss the original enthusiasm that drives you.
About fast enter play mode: Put videos about using this option because I’m scared to use it.

What is the recommended way to dispose IDisposables (e.g. NativeArray) with this feature enabled? Do we require to hook into EditorApplication.playModeStateChanged?

class Example : IDisposable{

  private NativeArray<Entity> Entities;

  public Example(){
    // How to correctly dispose this when exiting playmode?
   /*
     A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
     Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions)
   */
    Entities = new NativeArray<Entity>(count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
  }

  public void Dispose()
  {
    Entities.Dispose();
  }
}
1 Like

Hi @Joachim_Ante_1 ,

I may have found a comaptibility issue between adressable and the fast enter play mode :