/// <summary>Called when behaviour instance is being loaded</summary> public void Awake() { // Set the singleton instance if (GameBehaviour.Instance != null) { throw new InvalidOperationException("Only one instance of GameBehaviour is allowed per scene"); } GameBehaviour.Instance = this; // Resolve the asset loaders ResourceManager.RegisterResourceLoaders(GlobalContainer.ResolveAll <IResourceLoader>()); // Register the resource library singleton var resources = ResourceLibrary.FromString(this.ResourceLibraryXml.text); new DependencyContainer().RegisterSingleton <IResourceLibrary>(resources); // Create the IGame instance var gameDefinition = resources.GetSerializedResource <GameDefinition>(this.GameDefinitionId); this.game = (UnityGame)GlobalContainer.Resolve <IGameFactory>().Create(gameDefinition); //// Log.Trace("Loaded game '{0}' with {1} levels:\n{2}", this.game.Title, this.game.Levels.Length, string.Join("\n", this.game.Levels.Select(l => "{0} ({1})".FormatInvariant(l.Title, l.Id)).ToArray())); //// TODO: Drive level loading from a menu system // Load the first level var firstLevel = this.game.Levels.First().Id; Log.Trace("Loading level '{0}'...", firstLevel); this.game.LoadLevel(firstLevel); }