using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace SRDebugger.Services { public interface IDebugService { /// /// Current settings being used by the debugger /// Settings Settings { get; } /// /// True if the debug panel is currently being shown /// bool IsDebugPanelVisible { get; } /// /// True if the trigger is currently enabled /// bool IsTriggerEnabled { get; set; } /// /// True if new errors cause the trigger to display an error notification. /// Note: must also be true for notification to display. /// bool IsTriggerErrorNotificationEnabled { get; set; } IDockConsoleService DockConsole { get; } /// /// Access the SRDebugger console current filter states. /// IConsoleFilterState ConsoleFilter { get; } bool IsProfilerDocked { get; set; } /// /// Add to the system information tab. See for how to create /// an info instance. /// /// The entry to be added. /// The category the entry should be added to. void AddSystemInfo(InfoEntry entry, string category = "Default"); /// /// Show the debug panel /// /// /// If true and entry code is enabled in settings, the user will be prompted for a passcode /// before opening the panel. /// void ShowDebugPanel(bool requireEntryCode = true); /// /// Show the debug panel and open a certain tab /// /// Tab that will appear when the debug panel is opened /// /// If true and entry code is enabled in settings, the user will be prompted for a passcode /// before opening the panel. /// void ShowDebugPanel(DefaultTabs tab, bool requireEntryCode = true); /// /// Hide the debug panel /// void HideDebugPanel(); /// /// Set the entry code required to open the debug panel. /// Entry code requirement will be enabled if it is not already. /// /// If the user has already entered the correct pin code, their authorization will be reset /// and they will be required to enter the new pin code next time they open the debug panel. /// /// Use to disable the entry code requirement. /// /// New entry code. void SetEntryCode(EntryCode newCode); /// /// Disable the requirement for an entry code when opening the debug panel. /// Use to enable entry code the requirement again. /// void DisableEntryCode(); /// /// Hide the debug panel, then remove it from the scene to save memory. /// void DestroyDebugPanel(); /// /// Add all an objects compatible properties and methods to the options panel. /// NOTE: It is not recommended to use this on a MonoBehaviour, it should be used on a standard /// class made specifically for use as a settings object. /// /// The object to add. void AddOptionContainer(object container); /// /// Remove all properties and methods that the added to the options panel. /// /// The container to remove. void RemoveOptionContainer(object container); /// /// Add an option to the options panel. /// void AddOption(OptionDefinition option); /// /// Remove an option from the options panel. /// /// True if option was successfully removed, otherwise false. bool RemoveOption(OptionDefinition option); /// /// Pin all options in a category. /// /// void PinAllOptions(string category); /// /// Unpin all options in a category. /// /// void UnpinAllOptions(string category); void PinOption(string name); void UnpinOption(string name); /// /// Clear all pinned options. /// void ClearPinnedOptions(); /// /// Open a bug report sheet. /// /// Callback to invoke once the bug report is completed or cancelled. Null to ignore. /// /// Take a screenshot before opening the report sheet (otherwise a screenshot will be taken as /// the report is sent, if enabled in settings) /// /// Initial content of the bug report description void ShowBugReportSheet(ActionCompleteCallback onComplete = null, bool takeScreenshot = true, string descriptionContent = null); /// /// Event invoked whenever the debug panel opens or closes /// event VisibilityChangedDelegate PanelVisibilityChanged; event PinnedUiCanvasCreated PinnedUiCanvasCreated; /// /// ADVANCED FEATURE. This will convert the debug panel to a world space object and return the RectTransform. /// This can be used to position the SRDebugger panel somewhere in your scene. /// This feature is for advanced users only who know what they are doing. Only limited support will be provided /// for this method. /// The debug panel will be made visible if it is not already. /// /// The debug panel RectTransform. RectTransform EnableWorldSpaceMode(); /// /// Set a custom bug reporter handler. /// NOTE: This should be done on startup, ideally before the debug panel is opened. /// The visibility of the bug report tab will be determined when the debug panel opens so the bug reporter handler /// should be set before then. /// /// Custom bug report handler. void SetBugReporterHandler(IBugReporterHandler bugReporterHandler); } } namespace SRDebugger { public delegate void VisibilityChangedDelegate(bool isVisible); public delegate void ActionCompleteCallback(bool success); public delegate void PinnedUiCanvasCreated(RectTransform canvasTransform); public struct EntryCode : IReadOnlyList { public readonly int Digit1; public readonly int Digit2; public readonly int Digit3; public readonly int Digit4; public EntryCode(int digit1, int digit2, int digit3, int digit4) { if (digit1 < 0 || digit1 > 9) throw new ArgumentException("Pin digit must be between 0 and 9", "digit1"); if (digit2 < 0 || digit2 > 9) throw new ArgumentException("Pin digit must be between 0 and 9", "digit2"); if (digit3 < 0 || digit3 > 9) throw new ArgumentException("Pin digit must be between 0 and 9", "digit3"); if (digit4 < 0 || digit4 > 9) throw new ArgumentException("Pin digit must be between 0 and 9", "digit4"); Digit1 = digit1; Digit2 = digit2; Digit3 = digit3; Digit4 = digit4; } public IEnumerator GetEnumerator() { return new List { Digit1, Digit2, Digit3, Digit4 }.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public int Count { get { return 4; } } public int this[int index] { get { switch (index) { case 0: return Digit1; case 1: return Digit2; case 2: return Digit3; case 3: return Digit4; default: throw new ArgumentOutOfRangeException("index"); } } } } }