Exemple #1
0
        private void Load()
        {
            var dockService = SRServiceManager.GetService <IPinnedUIService>();

            if (dockService == null)
            {
                Debug.LogError("[DockConsoleService] PinnedUIService not found");
                return;
            }

            var pinService = dockService as PinnedUIServiceImpl;

            if (pinService == null)
            {
                Debug.LogError("[DockConsoleService] Expected IPinnedUIService to be PinnedUIServiceImpl");
                return;
            }

            _consoleRoot = pinService.DockConsoleController;

            _consoleRoot.SetDropdownVisibility(_isExpanded);
            _consoleRoot.IsVisible = _isVisible;
            _consoleRoot.SetAlignmentMode(_alignment);

            CheckTrigger();
        }
        public SRDebugService()
        {
            SRServiceManager.RegisterService <IDebugService>(this);

            // Load profiler
            SRServiceManager.GetService <IProfilerService>();

            // Setup trigger service
            _debugTrigger = SRServiceManager.GetService <IDebugTriggerService>();

            _informationService = SRServiceManager.GetService <ISystemInformationService>();

            _pinnedUiService = SRServiceManager.GetService <IPinnedUIService>();
            _pinnedUiService.OptionsCanvasCreated += transform =>
            {
                if (PinnedUiCanvasCreated == null)
                {
                    return;
                }
                try
                {
                    PinnedUiCanvasCreated(transform);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            };

            _optionsService = SRServiceManager.GetService <IOptionsService>();

            // Create debug panel service (this does not actually load any UI resources until opened)
            _debugPanelService = SRServiceManager.GetService <IDebugPanelService>();

            // Subscribe to visibility changes to provide API-facing event for panel open/close
            _debugPanelService.VisibilityChanged += DebugPanelServiceOnVisibilityChanged;

            _debugTrigger.IsEnabled = Settings.EnableTrigger == Settings.TriggerEnableModes.Enabled ||
                                      Settings.EnableTrigger == Settings.TriggerEnableModes.MobileOnly && Application.isMobilePlatform ||
                                      Settings.EnableTrigger == Settings.TriggerEnableModes.DevelopmentBuildsOnly && Debug.isDebugBuild;

            _debugTrigger.Position = Settings.TriggerPosition;

            if (Settings.EnableKeyboardShortcuts)
            {
                SRServiceManager.GetService <KeyboardShortcutListenerService>();
            }

            _entryCodeEnabled = Settings.Instance.RequireCode && Settings.Instance.EntryCode.Count == 4;

            if (Settings.Instance.RequireCode && !_entryCodeEnabled)
            {
                Debug.LogError("[SRDebugger] RequireCode is enabled, but pin is not 4 digits");
            }

            // Ensure that root object cannot be destroyed on scene loads
            var srDebuggerParent = Hierarchy.Get("SRDebugger");

            Object.DontDestroyOnLoad(srDebuggerParent.gameObject);
        }
Exemple #3
0
        private IEnumerator SubmitCo()
        {
            if (BugReportScreenshotUtil.ScreenshotData == null && Settings.Instance.EnableBugReportScreenshot)
            {
                if (TakingScreenshot != null)
                {
                    TakingScreenshot();
                }

                yield return(new WaitForEndOfFrame());

                yield return(StartCoroutine(BugReportScreenshotUtil.ScreenshotCaptureCo()));

                if (ScreenshotComplete != null)
                {
                    ScreenshotComplete();
                }
            }

            var s = SRServiceManager.GetService <IBugReportService>();

            var r = new BugReport();

            r.Email           = EmailField.text;
            r.UserDescription = DescriptionField.text;

            r.ConsoleLog        = Service.Console.AllEntries.ToList();
            r.SystemInformation = SRServiceManager.GetService <ISystemInformationService>().CreateReport();
            r.ScreenshotData    = BugReportScreenshotUtil.ScreenshotData;

            BugReportScreenshotUtil.ScreenshotData = null;

            s.SendBugReport(r, OnBugReportComplete, OnBugReportProgress);
        }
Exemple #4
0
        private void PromptEntryCode()
        {
            SRServiceManager.GetService <IPinEntryService>()
            .ShowPinEntry(Settings.Instance.EntryCode, SRDebugStrings.Current.PinEntryPrompt,
                          entered =>
            {
                if (entered)
                {
                    if (!Settings.Instance.RequireEntryCodeEveryTime)
                    {
                        _hasAuthorised = true;
                    }

                    if (_queuedTab.HasValue)
                    {
                        var t = _queuedTab.Value;

                        _queuedTab = null;
                        ShowDebugPanel(t, false);
                    }
                    else
                    {
                        ShowDebugPanel(false);
                    }
                }

                _queuedTab = null;
            });
        }
 public static void OnLoadBeforeScene()
 {
     if (Settings.Instance.IsEnabled)
     {
         // Initialize console if it hasn't already initialized.
         SRServiceManager.GetService <IConsoleService>();
     }
 }
        public StandardConsoleService()
        {
            Application.logMessageReceivedThreaded += UnityLogCallback;

            SRServiceManager.RegisterService <IConsoleService>(this);
            _collapseEnabled   = Settings.Instance.CollapseDuplicateLogEntries;
            _allConsoleEntries = new CircularBuffer <ConsoleEntry>(Settings.Instance.MaximumConsoleEntries);
        }
Exemple #7
0
    public static void Init()
    {
        // Initialize console if it hasn't already initialized.
        SRServiceManager.GetService <IConsoleService>();

        // Load the debug service
        SRServiceManager.GetService <IDebugService>();
    }
Exemple #8
0
    private static void PopulateObject(IList <FieldInfo> cache, SRMonoBehaviourEx instance, bool justSet)
    {
        for (var i = 0; i < cache.Count; i++)
        {
            var f = cache[i];

            if (!EqualityComparer <Object> .Default.Equals(f.Field.GetValue(instance), null))
            {
                continue;
            }

            // If import is enabled, use SRServiceManager to import the reference
            if (f.Import)
            {
                var t = f.ImportType ?? f.Field.FieldType;

                var service = SRServiceManager.GetService(t);

                if (service == null)
                {
                    Debug.LogWarning("Field {0} import failed (Type {1})".Fmt(f.Field.Name, t));
                    continue;
                }

                f.Field.SetValue(instance, service);

                continue;
            }

            // If autoset is enabled on field, try and find the component on the GameObject

            if (f.AutoSet)
            {
                var newValue = instance.GetComponent(f.Field.FieldType);

                if (!EqualityComparer <Object> .Default.Equals(newValue, null))
                {
                    f.Field.SetValue(instance, newValue);
                    continue;
                }
            }

            if (justSet)
            {
                continue;
            }

            if (f.AutoCreate)
            {
                var newValue = instance.CachedGameObject.AddComponent(f.Field.FieldType);
                f.Field.SetValue(instance, newValue);
            }

            throw new UnassignedReferenceException(
                      "Field {0} is unassigned, but marked with RequiredFieldAttribute".Fmt(f.Field.Name));
        }
    }
        public void Refresh()
        {
            var s = SRServiceManager.GetService <ISystemInformationService>();

            foreach (var kv in _infoBlocks)
            {
                FillInfoBlock(kv.Value, s.GetInfo(kv.Key));
            }
        }
        private void CreateTrigger()
        {
            var prefab = Resources.Load <TriggerRoot>(SRDebugPaths.TriggerPrefabPath);

            if (prefab == null)
            {
                Debug.LogError("[SRDebugger] Error loading trigger prefab");
                return;
            }

            _trigger = SRInstantiate.Instantiate(prefab);
            _trigger.CachedTransform.SetParent(CachedTransform, true);

            SetTriggerPosition(_trigger.TriggerTransform, _position);

            switch (Settings.Instance.TriggerBehaviour)
            {
            case Settings.TriggerBehaviours.TripleTap:
            {
                _trigger.TripleTapButton.onClick.AddListener(OnTriggerButtonClick);
                _trigger.TapHoldButton.gameObject.SetActive(false);

                break;
            }

            case Settings.TriggerBehaviours.TapAndHold:
            {
                _trigger.TapHoldButton.onLongPress.AddListener(OnTriggerButtonClick);
                _trigger.TripleTapButton.gameObject.SetActive(false);

                break;
            }

            case Settings.TriggerBehaviours.DoubleTap:
            {
                _trigger.TripleTapButton.RequiredTapCount = 2;
                _trigger.TripleTapButton.onClick.AddListener(OnTriggerButtonClick);
                _trigger.TapHoldButton.gameObject.SetActive(false);

                break;
            }

            default:
                throw new Exception("Unhandled TriggerBehaviour");
            }

            SRDebuggerUtil.EnsureEventSystemExists();

            UnityEngine.SceneManagement.SceneManager.activeSceneChanged += OnActiveSceneChanged;

            if (Settings.Instance.ErrorNotification)
            {
                _consoleService        = SRServiceManager.GetService <IConsoleService>();
                _consoleService.Error += OnError;
            }
        }
    public static void Init()
    {
        if (!SRServiceManager.HasService <IConsoleService>())
        {
            // Force console service to be created early, so it catches more of the initialization log.
            new StandardConsoleService();
        }

        // Load the debug service
        SRServiceManager.GetService <IDebugService>();
    }
Exemple #12
0
 public void Close()
 {
     if (Settings.Instance.UnloadOnClose)
     {
         SRServiceManager.GetService <IDebugService>().DestroyDebugPanel();
     }
     else
     {
         SRServiceManager.GetService <IDebugService>().HideDebugPanel();
     }
 }
Exemple #13
0
        public static void OnLoadBeforeScene()
        {
            // Populate service manager with types from SRDebugger assembly (asmdef)
            SRServiceManager.RegisterAssembly <IDebugService>();

            if (Settings.Instance.IsEnabled)
            {
                // Initialize console if it hasn't already initialized.
                SRServiceManager.GetService <IConsoleService>();
            }
        }
Exemple #14
0
        public StandardConsoleService()
        {
#if UNITY_5 || UNITY_5_3_OR_NEWER
            Application.logMessageReceivedThreaded += UnityLogCallback;
#else
            Application.RegisterLogCallbackThreaded(UnityLogCallback);
#endif

            SRServiceManager.RegisterService <IConsoleService>(this);
            _collapseEnabled   = Settings.Instance.CollapseDuplicateLogEntries;
            _allConsoleEntries = new CircularBuffer <ConsoleEntry>(Settings.Instance.MaximumConsoleEntries);
        }
        public StandardConsoleService()
        {
#if UNITY_5
            Application.logMessageReceived += UnityLogCallback;
#else
            Application.RegisterLogCallback(UnityLogCallback);
#endif

            SRServiceManager.RegisterService <IConsoleService>(this);

            _collapseEnabled = Settings.Instance.CollapseDuplicateLogEntries;

            _allConsoleEntriesReadOnly = _allConsoleEntries.AsReadOnly();
            _consoleEntriesReadOnly    = _consoleEntries.AsReadOnly();
        }
Exemple #16
0
        public void ShowBugReportSheet(ActionCompleteCallback onComplete = null, bool takeScreenshot = true, string descriptionContent = null)
        {
            var popoverService = SRServiceManager.GetService <BugReportPopoverService>();

            if (popoverService.IsShowingPopover)
            {
                return;
            }

            popoverService.ShowBugReporter((succeed, message) => {
                if (onComplete != null)
                {
                    onComplete(succeed);
                }
            }, takeScreenshot, descriptionContent);
        }
        public void Refresh()
        {
            var s = SRServiceManager.GetService <ISystemInformationService>();

            foreach (var category in s.GetCategories())
            {
                if (!_infoBlocks.ContainsKey(category))
                {
                    var block = CreateBlock(category);
                    _infoBlocks.Add(category, block);
                }
            }

            foreach (var kv in _infoBlocks)
            {
                FillInfoBlock(kv.Value, s.GetInfo(kv.Key));
            }
        }
        private void Construct()
        {
            var s = SRServiceManager.GetService <ISystemInformationService>();

            foreach (var category in s.GetCategories())
            {
                var info = s.GetInfo(category);

                if (info.Count == 0)
                {
                    continue;
                }

                var block = CreateBlock(category);
                FillInfoBlock(block, info);

                _infoBlocks.Add(category, block);
            }
        }
Exemple #19
0
        public SRDebugService()
        {
            SRServiceManager.RegisterService <IDebugService>(this);

            // Load profiler
            SRServiceManager.GetService <IProfilerService>();

            // Setup trigger service
            _debugTrigger = SRServiceManager.GetService <IDebugTriggerService>();

            // Create debug panel service (this does not actually load any UI resources until opened)
            _debugPanelService = SRServiceManager.GetService <IDebugPanelService>();

            // Subscribe to visibility changes to provide API-facing event for panel open/close
            _debugPanelService.VisibilityChanged += DebugPanelServiceOnVisibilityChanged;

            _debugTrigger.IsEnabled = Settings.EnableTrigger == Settings.TriggerEnableModes.Always ||
                                      Settings.EnableTrigger == Settings.TriggerEnableModes.MobileOnly &&
                                      Application.isMobilePlatform;

            _debugTrigger.Position = Settings.TriggerPosition;

            if (Settings.EnableKeyboardShortcuts)
            {
                SRServiceManager.GetService <KeyboardShortcutListenerService>();
            }

            _entryCodeEnabled = Settings.Instance.RequireCode && Settings.Instance.EntryCode.Count == 4;

            if (Settings.Instance.RequireCode && !_entryCodeEnabled)
            {
                Debug.LogError("[SRDebugger] RequireCode is enabled, but pin is not 4 digits");
            }

            // Ensure that root object cannot be destroyed on scene loads
            var srDebuggerParent = Hierarchy.Get("SRDebugger");

            Object.DontDestroyOnLoad(srDebuggerParent.gameObject);
        }
 protected override void Awake()
 {
     base.Awake();
     _profilerService = SRServiceManager.GetService <IProfilerService>();
 }
 public void Close()
 {
     SRServiceManager.GetService <IDebugService>().HideDebugPanel();
 }
Exemple #22
0
 public void CloseAndDestroy()
 {
     SRServiceManager.GetService <IDebugService>().DestroyDebugPanel();
 }
Exemple #23
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     SRServiceManager.UnRegisterService <T>();
 }
Exemple #24
0
 protected override void Awake()
 {
     base.Awake();
     SRServiceManager.RegisterService <T>(this);
 }
Exemple #25
0
 public static void OnStartup()
 {
     SRServiceManager.GetService <SRDebugger.Internal.InternalOptionsRegistry>().AddOptionContainer(Current);
 }