/// <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); }
/// <summary> /// Start the LoadSystemScene shortly before the first update /// </summary> public void Start() { UnityGame game = GameObject.FindObjectOfType <UnityGame>(); if (game == null) { Application.LoadLevelAdditive(this.SystemSceneName); } }
internal void Awake() { DontDestroyOnLoad(gameObject); if (!initialized) { UnityGame.SetMainThread(); UnityGame.EnsureRuntimeGameVersion(); PluginManager.Load(); bsPlugins = new CompositeBSPlugin(PluginManager.BSMetas); #pragma warning disable 618 ipaPlugins = new CompositeIPAPlugin(PluginManager.Plugins); #pragma warning restore 618 /* #if BeatSaber // TODO: remove this * gameObject.AddComponent<Updating.BeatMods.Updater>(); #endif */ bsPlugins.OnEnable(); ipaPlugins.OnApplicationStart(); SceneManager.activeSceneChanged += OnActiveSceneChanged; SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; var unitySched = UnityMainThreadTaskScheduler.Default as UnityMainThreadTaskScheduler; if (!unitySched.IsRunning) { StartCoroutine(unitySched.Coroutine()); } initialized = true; #if DEBUG Config.Stores.GeneratedStoreImpl.DebugSaveAssembly("GeneratedAssembly.dll"); #endif } }
void Awake() { DontDestroyOnLoad(gameObject); if (!initialized) { UnityGame.SetMainThread(); UnityGame.EnsureRuntimeGameVersion(); PluginManager.Load(); bsPlugins = new CompositeBSPlugin(PluginManager.BSMetas); #pragma warning disable 618 ipaPlugins = new CompositeIPAPlugin(PluginManager.Plugins); #pragma warning restore 618 #if BeatSaber gameObject.AddComponent <Updating.BeatMods.Updater>(); #endif bsPlugins.OnEnable(); ipaPlugins.OnApplicationStart(); SceneManager.activeSceneChanged += OnActiveSceneChanged; SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; var unitySched = UnityMainThreadTaskScheduler.Default as UnityMainThreadTaskScheduler; if (!unitySched.IsRunning) { StartCoroutine(unitySched.Coroutine()); } initialized = true; } }
private void Start() { eaters = FindObjectsOfType <UnityEater>().ToList(); chefs = FindObjectsOfType <UnityChef>().ToList(); game = FindObjectOfType <UnityGame>(); }
/// <summary> /// Initialize the event dispatcher. /// </summary> public void Start() { // If this is null, let there be exception carnage. this.Game = GameObject.FindObjectOfType <UnityGame>(); }
public void Awake() { game = GetComponentInChildren <UnityGame>(); spawner = GetComponentInChildren <FoodSpawner>(); }
private static void _Load() { UnityGame.SetEarlyGameVersion(SafeParseVersion()); UnityGame.CheckGameVersionBoundary(); }