public void InitializeFramework(ConfigBuilder configBuilder, Action <IContainer, IMessageBus, ITrace, GameRunner> bootInitAction) { // Setup main thread scheduler Scheduler.MainThread = UnityMainThreadScheduler.MainThread; // Create and register DebugConsole inside Container _container = new Container(); // Create message bus class which is way to listen for ASM events _messageBus = new MessageBus(); // Create trace to log important messages _trace = new DebugConsoleTrace(); // Subscribe to unhandled exceptions in RX UnityMainThreadDispatcher.RegisterUnhandledExceptionCallback(ex => _trace.Error(FatalCategoryName, ex, "Unhandled exception")); // Console is way to debug/investigate app behavior on real devices when // regular debugger is not applicable CreateConsole(true); try { // NOTE These services should be registered inside container before GameRunner is constructed. // Trace implementation _container.RegisterInstance <ITrace>(_trace); // Path resolver which knows about current platform _container.RegisterInstance <IPathResolver>(new PathResolver()); // Message bus _container.RegisterInstance(_messageBus); // File system service _container.Register(Component.For <IFileSystemService>() #if UNITY_WEBPLAYER .Use <WebFileSystemService>().Singleton()); #else .Use <FileSystemService>().Singleton()); #endif // Build config with default settings var config = configBuilder #if UNITY_WEBPLAYER .SetSandbox(true) #endif .Build(); // Create ASM entry point with settings provided, register custom plugin(-s) which add(-s) // custom logic or replaces default one. Then run bootstrapping process which populates container // with defined implementations. _gameRunner = new GameRunner(_container, config); // provide the way to insert different custom extensions for different scenes bootInitAction(_container, _messageBus, _trace, _gameRunner); // run bootstrappering _gameRunner.Bootstrap(); }
public void Awake() { Instance = this; }