internal static void Repeat(OperationTreeDescription treeDescription, int?repeatCount = null) { var isCounted = repeatCount.HasValue; var count = 0; var controlOp = new Operation(endAction: () => { if (isCounted) { count++; } if (isCounted && count >= repeatCount) { return; } var isCancelled = treeDescription.IsCancelled(); if (isCancelled) { ManagedLog.Log($"Not restarting {nameof(OperationTreeDescription)}, root: {treeDescription.Root.Name}", ManagedLog.Type.Verbose); } else { ManagedLog.Log($"Restarting {nameof(OperationTreeDescription)}, root: {treeDescription.Root.Name}", ManagedLog.Type.Verbose); treeDescription.Start(); } }); treeDescription.AddOperation(controlOp); if (!treeDescription.IsWaitingOrRunning()) { treeDescription.Start(); } }
private static void AddAllComponentsInScene <T>(Scene arg0) where T : Component { var addedCount = 0; var allObjectsInScene = arg0.GetRootGameObjects(); foreach (var gameObject in allObjectsInScene) { var components = gameObject.GetComponentsInChildren <T>(); addedCount += components.Length; switch (components) { case View[] views: Views.AddRange(views); foreach (var view in views) { view.Internal_OnLoad(); } break; case ControllerBase[] controllers: Controllers.AddRange(controllers); break; } } if (addedCount > 0) { ManagedLog.Log($"Added {addedCount} {typeof(T).Name} from {arg0.name} scene.", ManagedLog.Type.Structure); } }
private static void LogUpdate(object msg) { if (!_logDrawUpdates) { return; } ManagedLog.Log(msg); }
private static void LogEvent(object msg) { if (!_logEvents) { return; } ManagedLog.Log(msg, ManagedLog.Type.Structure); }
private void OnValidate() { if (!_rigidbody) { _rigidbody = GetComponent <Rigidbody>(); } if (!_rigidbody) { _rigidbody = gameObject.AddComponent <Rigidbody>(); _rigidbody.isKinematic = true; ManagedLog.Log($"Added Rigidbody to {name}.", ManagedLog.Type.Info); } }
private static void CheckLevelEnterPlayModeForLoadingMainScene() { if (!ProjectEditorConfig.Instance.AutoTestLevelScenes) { return; } // No game exists var game = FindAllObjects.InScene <GameBase>().FirstOrDefault(); if (game) { return; } // Found level helper var sceneRef = FindAllObjects.InScene <LevelSceneRefBase>(); if (sceneRef.Length <= 0) { return; } ManagedLog.Log($"Loading main scene to test {SceneManager.GetActiveScene().name}"); var testingScene = AssetDatabase.LoadAssetAtPath <SceneAsset>(SceneManager.GetActiveScene().path); GameWindow.TestLevel = AssetDatabase.LoadAssetAtPath <SceneAsset>(SceneManager.GetActiveScene().path); _asyncOperation = EditorSceneManager.LoadSceneAsyncInPlayMode(GameWindow.MainSceneAssetPath, new LoadSceneParameters(LoadSceneMode.Single)); _asyncOperation.completed += OnloadComplete; void OnloadComplete(AsyncOperation obj) { game = FindAllObjects.InScene <GameBase>().FirstOrDefault(); _asyncOperation.completed -= OnloadComplete; Assert.IsNotNull(game); #if USING_SHAPES WorldLog.OnScreen($"Testing {testingScene.name}"); #endif new Operation(delay: 1f, action: () => { game.StartGame(); }).Start(); } }
internal static void RegisterViewOrController(Object obj) { switch (obj) { case View view: Views.Add(view); break; case ControllerBase controllerBase: Controllers.Add(controllerBase); break; default: return; } ManagedLog.Log($"Registered new {obj.GetType().Name} ({obj.GetScenePath()})", ManagedLog.Type.Structure); }
private static void LogTimeScale() => ManagedLog.Log($"TimeScale: {Time.timeScale}", avoidFrameCount: true);
// Disabled for now /* #region Access Restriction * * // ReSharper disable once InconsistentNaming * public new GameObject gameObject * { * get * { * Debug.LogWarning($"Shouldn't access {nameof(gameObject)} of {nameof(ControllerBase)}"); * return base.gameObject; * } * } * * // ReSharper disable once InconsistentNaming * public new Transform transform * { * get * { * * Debug.LogWarning($"Shouldn't access {nameof(transform)} of {nameof(ControllerBase)}"); * return base.transform; * } * } * * // ReSharper disable once InconsistentNaming * public new bool enabled * { * get * { * Debug.LogWarning($"Shouldn't access {nameof(enabled)} of {nameof(ControllerBase)}"); * return base.enabled; * } * set * { * Debug.LogWarning($"Shouldn't access {nameof(enabled)} of {nameof(ControllerBase)}"); * base.enabled = value; * } * } * #endregion */ #region Logging Helper Methods protected void Log(object obj, ManagedLog.Type type = ManagedLog.Type.Default, Object context = null) => ManagedLog.Log(obj, type, context ? context : this);
internal void InternalOnLevelStop() { ManagedLog.Log($"{GetType().Name}.{nameof(InternalOnLevelStop)} ({this.GetScenePath()})", ManagedLog.Type.Verbose); OnLevelDidStop(); }
internal void InternalOnLevelStart(MainSceneRefBase levelData, TLevelSceneRefBase levelSceneRef) { ManagedLog.Log($"{GetType().Name}.{nameof(InternalOnLevelStart)} ({this.GetScenePath()})", ManagedLog.Type.Verbose); OnLevelDidStart(levelData as TMainSceneRefBase, levelSceneRef); }