示例#1
0
        private static void InitScene(Scene scene)
        {
            GameWindow.Log($"Initializing scene {scene.name}");

            _scene = scene;

            _game          = FindObjectOfType <GameBase>();
            _levelSceneRef = FindObjectOfType <LevelSceneRefBase>();

            // Check if valid Scene
            if (IsValidGameScene)
            {
                _staticConfig = ReflectionHelper.GetPropertyOrField(_game, "_Config") as ConfigBase;

                _staticLevelManager = ReflectionHelper.GetPropertyOrField(_game, "_SceneLevelManager") as SceneLevelManager;
                _gameEvents         = ReflectionHelper.GetPropertyOrField(_game, "_GameEvents") as GameEvents;

                GameWindow.Log($"{scene.name} is valid Game scene.");
            }
            else if (_levelSceneRef)
            {
                GameWindow.Log($"{scene.name} Is valid Level scene.");
            }

            // Find Config and SceneLevelManager in project if not a valid game scene
            if (!IsValidGameScene)
            {
                _staticConfig       = FindInProject.AssetByType <ConfigBase>();
                _staticLevelManager = FindInProject.AssetByType <SceneLevelManager>();
            }
        }
示例#2
0
        private static void FindConfig()
        {
#if UNITY_EDITOR
            _config = FindInProject.AssetByType <ManagedLogConfig>();
            // var managedLogConfigs = FindAllObjects.InEditor<ManagedLogConfig>();

            // if (managedLogConfigs.Count > 0)
            // _config = managedLogConfigs.First();
            // else if (managedLogConfigs.Count == 0)
            // _config = AssetDatabase.LoadAssetAtPath<ManagedLogConfig>(assetPath);

            if (!_config)
            {
                Debug.LogError($"Can't find config file for {typeof(ManagedLog)}, creating one!");
                var asset = ScriptableObject.CreateInstance <ManagedLogConfig>();
                AssetDatabase.CreateAsset(asset, CreationPath);
                AssetDatabase.SaveAssets();
            }
#endif
        }