Framework Version
11.0.5
Unity Version
2022.3.30f1
Current Behavior
Calling a UniTask async method inside a service constructor do not works when the service is a pure class and has the "RequiredService" and "PreloadService" attributes.
Expected Behavior
Be able to run async methods called by the service construtor.
Steps to Reproduce
Create a interface that implements IService with RequiredService attribute
Create a pure class that implements the interface with PreloadService attribute
Declare a async method that awaits for any type of UniTask method
Call this method inside the service constructor
Basically, PlayerLoop is not initialized when calling the service constructor
I was able to implement this workaround to fix the problem:
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
public static void InitializePlayerLoop()
{
PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();
PlayerLoopHelper.Initialize(ref currentPlayerLoop);
}
Framework Version
11.0.5
Unity Version
2022.3.30f1
Current Behavior
Calling a UniTask async method inside a service constructor do not works when the service is a pure class and has the "RequiredService" and "PreloadService" attributes.
Expected Behavior
Be able to run async methods called by the service construtor.
Steps to Reproduce
Create a interface that implements IService with RequiredService attribute
Create a pure class that implements the interface with PreloadService attribute
Declare a async method that awaits for any type of UniTask method
Call this method inside the service constructor
Basically, PlayerLoop is not initialized when calling the service constructor
I was able to implement this workaround to fix the problem: