void Awake() { _Instance = this; // assign references if (_HUDNavigationCanvas == null) { _HUDNavigationCanvas = HUDNavigationCanvas.Instance; // check if HUDNavigationCanvas exists if (_HUDNavigationCanvas == null) { Debug.LogError("HUDNavigationCanvas not found in scene!"); this.enabled = false; return; } } // assign references if (PlayerCamera == null && Camera.main != null) { PlayerCamera = Camera.main; } // check references if (PlayerCamera == null || PlayerController == null) { Debug.LogError("Player references are missing! Please assign them on the HUDNavigationSystem component."); this.enabled = false; return; } // init all components InitAllComponents(); }
void Awake() { // destroy duplicate instances if (_Instance != null) { Destroy(this.gameObject); return; } _Instance = this; DontDestroyOnLoad(this.gameObject); }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { // assign references if (_HUDNavigationSystem == null) { _HUDNavigationSystem = HUDNavigationSystem.Instance; // check if HUDNavigationSystem exists if (_HUDNavigationSystem == null) { Debug.LogError("HUDNavigationSystem not found in scene!"); this.enabled = false; return; } } // return if HUDNavigationSystem is not initialized (yet) if (_HUDNavigationSystem == null) { return; } // return if no configuration is assigned if (Configurations.Count <= 0) { return; } // get configuration matching currently active scene Configuration config = Configurations.Where(c => c._Scene != null && c._Config != null && c._Scene.path.Equals(scene.path)).FirstOrDefault(); if (config._Config == null) { return; } // apply configuration HNSSceneConfiguration sceneConfig = config._Config; _HUDNavigationSystem.ApplySceneConfiguration(sceneConfig); }
void StartQuickSetup() { if (goPlayer == null || goCamera == null) { return; } // add hud navigation system to player HUDNavigationSystem hudSystem = goPlayer.GetComponent <HUDNavigationSystem> (); if (hudSystem == null) { hudSystem = goPlayer.AddComponent <HUDNavigationSystem> (); } // assign references hudSystem.PlayerController = goPlayer.transform; hudSystem.PlayerCamera = goCamera; // add hud navigation canvas to scene HUDNavigationCanvas hudCanvas = GameObject.FindObjectOfType <HUDNavigationCanvas> (); if (hudCanvas == null) { // add canvas prefab from assets to scene GameObject hudPrefab = Resources.Load("Prefabs/HUD Navigation Canvas") as GameObject; if (hudPrefab != null) { GameObject hudGO = Instantiate(hudPrefab) as GameObject; hudGO.name = "HUD Navigation Canvas"; } } // console output Debug.LogFormat("'{0}' was successfully added to the scene.", HNS.Name); // close editor window window.Close(); }