using System.Collections; using System.Collections.Generic; using UnityEngine; using MoreMountains.Tools; namespace MoreMountains.Feedbacks { /// /// This feedback will let you output a message to the console, using a custom MM debug method, or Log, Assertion, Error or Warning logs. /// [AddComponentMenu("")] [FeedbackHelp("This feedback will let you output a message to the console, using a custom MM debug method, or Log, Assertion, Error or Warning logs.")] [FeedbackPath("Debug/Log")] public class MMFeedbackDebugLog : MMFeedback { /// the duration of this feedback is the duration of the light, or 0 if instant public override float FeedbackDuration { get { return 0f; } } /// sets the inspector color for this feedback #if UNITY_EDITOR public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.DebugColor; } } #endif /// the possible debug modes public enum DebugLogModes { DebugLogTime, Log, Assertion, Error, Warning } [Header("Debug")] /// the selected debug mode [Tooltip("the selected debug mode")] public DebugLogModes DebugLogMode = DebugLogModes.DebugLogTime; /// the message to display [Tooltip("the message to display")] [TextArea] public string DebugMessage; /// the color of the message when in DebugLogTime mode [Tooltip("the color of the message when in DebugLogTime mode")] [MMEnumCondition("DebugLogMode", (int) DebugLogModes.DebugLogTime)] public Color DebugColor = Color.cyan; /// whether or not to display the frame count when in DebugLogTime mode [Tooltip("whether or not to display the frame count when in DebugLogTime mode")] [MMEnumCondition("DebugLogMode", (int) DebugLogModes.DebugLogTime)] public bool DisplayFrameCount = true; /// /// On Play we output our message to the console using the selected mode /// /// /// protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { if (Active) { switch (DebugLogMode) { case DebugLogModes.Assertion: Debug.LogAssertion(DebugMessage); break; case DebugLogModes.Log: Debug.Log(DebugMessage); break; case DebugLogModes.Error: Debug.LogError(DebugMessage); break; case DebugLogModes.Warning: Debug.LogWarning(DebugMessage); break; case DebugLogModes.DebugLogTime: string color = "#" + ColorUtility.ToHtmlStringRGB(DebugColor); MMDebug.DebugLogTime(DebugMessage, color, 3, DisplayFrameCount); break; } } } } }