Exemple #1
0
        private void Start()
        {
            // Initialize loader
            _loader = new ZenjectSceneLoader(GetComponent <SceneContext>(), GetComponentInParent <ProjectKernel>());

            // If there is no instance of this class, set it.
            if (Instance == null)
            {
                Instance = this;
                if (SplashObj != null)
                {
                    _canvasObj = Instantiate(SplashObj);
                    _canvasObj.transform.SetParent(transform);
                    _canvasObj.transform.position = Vector3.zero;
                    _splashCanvasGroup            = _canvasObj.GetComponentInChildren <CanvasGroup>();
                    _canvasObj.GetComponent <Canvas>().sortingOrder = 999;

                    DontDestroyOnLoad(SplashObj);
                }

                Instance.StartCoroutine(LoadLevelFadeIn(DefaultScene.Trim(), true, false));
            }
            else
            {
                Debug.LogError("There is already a SceneController in the scene.");
                Destroy(this);
            }
        }
Exemple #2
0
        /// <summary>
        ///     Injects necessary dependencies and initializes the object.
        /// </summary>
        public void Initialize(SceneService sceneController, MusicManager musicManager, JsonService jsonManager)
        {
            if (_isInitialized)
            {
                throw new InvalidOperationException("Already initialized.");
            }

            if (sceneController == null)
            {
                throw new ArgumentNullException(nameof(sceneController));
            }

            if (musicManager == null)
            {
                throw new ArgumentNullException(nameof(musicManager));
            }

            if (jsonManager == null)
            {
                throw new ArgumentNullException(nameof(jsonManager));
            }

            _isInitialized = true;
        }