コード例 #1
0
        internal static IEnumerable <ResourceDirectory> GetResourcePaths()
        {
            foreach (string resourcePath in _resourcePaths)
            {
                string enabledPath  = Path.Combine(SRInternalEditorUtil.GetRootPath(), resourcePath);
                string disabledPath = Path.Combine(SRInternalEditorUtil.GetRootPath(), resourcePath) + DisabledDirectoryPostfix;

                yield return(new ResourceDirectory(enabledPath, disabledPath));
            }
        }
コード例 #2
0
ファイル: Migrations.cs プロジェクト: malering/ET
        public static void RunMigration(Migration migration)
        {
            if (EnableLog)
            {
                Debug.Log("Running Migration: " + migration.Id);
            }

            var assetPaths = AssetDatabase.GetAllAssetPaths();
            var root       = new DirectoryInfo(SRInternalEditorUtil.GetRootPath());

            if (EnableLog)
            {
                Debug.Log("Using Root Path: " + root.FullName);
            }

            var obsoleteAssets = migration.ObsoleteFiles.Select(p => root + "/" + p).ToList();
            var deleteQueue    = assetPaths.Where(assetPath => obsoleteAssets.Contains(assetPath)).ToList();

            if (deleteQueue.Count == 0)
            {
                return;
            }

            var message = "The following files used by a previous version of SRDebugger are obsolete and can be safely deleted: \n\n" +
                          deleteQueue.Aggregate((s1, s2) => s1 + "\n" + s2);

            Debug.Log(message);

            message += "\n\nIt is recommended to delete these files.";

            if (EditorUtility.DisplayDialog("SRDebugger Migration Assistant",
                                            message, "Delete Now", "Ignore"))
            {
                foreach (var s in deleteQueue)
                {
                    Debug.Log("[SRDebugger] Deleting Asset {0}".Fmt(s));

                    if (!AssetDatabase.DeleteAsset(s))
                    {
                        Debug.LogWarning("[SRDebugger] Error deleting asset {0}".Fmt(s));
                    }
                }

                Debug.Log("[SRDebugger] Migration Complete");
            }
            else
            {
                EditorUtility.DisplayDialog("SRDebugger Migration Assitant",
                                            "You can run this migration check again via the \"Run Migrations\" button in the advanced tab of the SRDebugger settings window.", "OK");
            }
        }
コード例 #3
0
ファイル: SRDebugEditor.cs プロジェクト: malering/ET
        internal static void DrawDisabledWindowGui(ref bool isWorking)
        {
            SRInternalEditorUtil.BeginDrawBackground();
            SRInternalEditorUtil.DrawLogo(SRInternalEditorUtil.GetLogo());
            SRInternalEditorUtil.EndDrawBackground();

            // Draw header/content divider
            EditorGUILayout.BeginVertical(SRInternalEditorUtil.Styles.SettingsHeaderBoxStyle);
            EditorGUILayout.EndVertical();

            GUILayout.Label("SRDebugger Disabled", SRInternalEditorUtil.Styles.InspectorHeaderStyle);

            GUILayout.Label(
                "SRDebugger is currently disabled. SRDebugger must be enabled in order to access editor features.",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            EditorGUILayout.HelpBox("Enabling SRDebugger will result in the tools being included in all builds of your game until it is disabled again.", MessageType.Warning);

            GUILayout.Label("• " + DisableSRDebuggerCompileDefine + " compiler define will be removed from all build configurations.", SRInternalEditorUtil.Styles.ListBulletPoint);
            GUILayout.Label("• Disabled SRDebugger folders will be renamed so Unity imports them.", SRInternalEditorUtil.Styles.ListBulletPoint);
            GUILayout.Label("• You can disable SRDebugger again at any time.", SRInternalEditorUtil.Styles.ListBulletPoint);

            if (isWorking && !EditorApplication.isCompiling && !EditorApplication.isUpdating)
            {
                isWorking = false;
            }

            if (isWorking)
            {
                using (new EditorGUI.DisabledGroupScope(true))
                {
                    GUILayout.Button("Working...");
                }
            }
            else if (GUILayout.Button("Enable SRDebugger"))
            {
                isWorking = true;
                try
                {
                    SetEnabled(true);
                }
                catch (Exception)
                {
                    isWorking = false;
                    throw;
                }
            }
        }
コード例 #4
0
        static void SetResourcesEnabled(bool enable)
        {
            AssetDatabase.StartAssetEditing();

            foreach (ResourceDirectory d in GetResourcePaths())
            {
                d.SetDirectoryEnabled(enable);
            }

            AssetDatabase.StopAssetEditing();

            AssetDatabase.Refresh();

            AssetDatabase.ImportAsset(SRInternalEditorUtil.GetRootPath(
                                          ), ImportAssetOptions.ImportRecursive | ImportAssetOptions.ForceUpdate);
        }
コード例 #5
0
        private void DrawVideo()
        {
            if (_demoSprite == null)
            {
                _demoSprite = SRInternalEditorUtil.LoadResource <Texture2D>("Editor/DemoSprite.png");
            }

            if (_demoSprite == null)
            {
                return;
            }

            var frameWidth       = 400;
            var frameHeight      = 300;
            var framePadding     = 0;
            var extraFramesStart = 5;
            var extraFramesEnd   = 20;
            var totalFrames      = 29;
            var fps = 16f;

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            var rect = GUILayoutUtility.GetRect(400 * 0.75f, 300 * 0.75f, GUILayout.ExpandHeight(false),
                                                GUILayout.ExpandWidth(false));

            var frame = ((int)(EditorApplication.timeSinceStartup * fps)) %
                        (totalFrames + extraFramesStart + extraFramesEnd);

            frame -= extraFramesStart;

            var actualFrame = Mathf.Clamp(frame, 0, totalFrames);

            SRInternalEditorUtil.RenderGif(rect, _demoSprite, actualFrame, frameWidth, frameHeight, 5, framePadding,
                                           framePadding);

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
        }
コード例 #6
0
ファイル: SettingsEditor.cs プロジェクト: malering/ET
        public override void OnInspectorGUI()
        {
            SRInternalEditorUtil.DrawLogo(SRInternalEditorUtil.GetLogo());

            GUILayout.Label(
                "This asset contains the runtime settings used by SRDebugger. It is recommended that this asset be edited only via the SRDebugger Settings window.",
                EditorStyles.wordWrappedLabel);

            EditorGUILayout.Separator();

            if (GUILayout.Button("Open SRDebugger Settings Window"))
            {
                SRDebuggerSettingsWindow.Open();
            }

            if (!_override)
            {
                if (GUILayout.Button("Override Warning"))
                {
                    _override = true;
                }
            }
            else
            {
                GUILayout.Label(
                    "You have been warned...",
                    EditorStyles.wordWrappedLabel);
            }

            EditorGUILayout.Separator();

            if (_override)
            {
                base.OnInspectorGUI();
            }
        }
コード例 #7
0
        private void OnGUI()
        {
            // Draw header area
            SRInternalEditorUtil.BeginDrawBackground();
            SRInternalEditorUtil.DrawLogo(SRInternalEditorUtil.GetWelcomeLogo());
            SRInternalEditorUtil.EndDrawBackground();

            // Draw header/content divider
            EditorGUILayout.BeginVertical(SRInternalEditorUtil.Styles.SettingsHeaderBoxStyle);
            EditorGUILayout.EndVertical();

            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

            GUILayout.Label("Welcome", SRInternalEditorUtil.Styles.HeaderLabel);

            GUILayout.Label(
                "Thank you for purchasing SRDebugger, your support is very much appreciated and we hope you find it useful for your project. " +
                "This window contains a quick guide to get to help get you started with SRDebugger.",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            if (SRInternalEditorUtil.ClickableLabel(
                    "Note: For more detailed information <color={0}>click here</color> to visit the online documentation."
                    .Fmt(SRInternalEditorUtil.Styles.LinkColour),
                    SRInternalEditorUtil.Styles.ParagraphLabel))
            {
                Application.OpenURL(SRDebugEditorStrings.Current.SettingsDocumentationUrl);
            }

            GUILayout.Label("Quick Start", SRInternalEditorUtil.Styles.HeaderLabel);
            GUILayout.Label(
                "Now that you have imported the package, you should find the trigger available in the top-left of your game window when in play mode. " +
                "Triple-clicking this trigger will bring up the debug panel. The trigger is hidden until clicked.",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            GUILayout.Label(
                "By default, SRDebugger loads automatically when your game starts. " +
                "You can change this behaviour from the SRDebugger Settings window.",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            DrawVideo();

            EditorGUILayout.Space();

            GUILayout.Label("Customization", SRInternalEditorUtil.Styles.HeaderLabel);

            if (SRInternalEditorUtil.ClickableLabel(
                    "Many features of SRDebugger can be configured from the <color={0}>SRDebugger Settings</color> window."
                    .Fmt(
                        SRInternalEditorUtil.Styles.LinkColour), SRInternalEditorUtil.Styles.ParagraphLabel))
            {
                SRDebuggerSettingsWindow.Open();
            }

            GUILayout.Label(
                "From the settings window you can configure loading behaviour, trigger position, docked tools layout, and more. " +
                "You can enable the bug reporter service by using the sign-up form to get a free API key.",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            GUILayout.Label("What Next?", SRInternalEditorUtil.Styles.HeaderLabel);

            if (SRInternalEditorUtil.ClickableLabel(
                    "For more detailed information about SRDebugger's features or details about the Options Tab and script API, check the <color={0}>online documentation</color>."
                    .Fmt(SRInternalEditorUtil.Styles.LinkColour), SRInternalEditorUtil.Styles.ParagraphLabel))
            {
                Application.OpenURL(SRDebugEditorStrings.Current.SettingsDocumentationUrl);
            }

            GUILayout.Label(
                "Thanks again for purchasing SRDebugger. " +
                "If you find it useful please consider leaving a rating or review on the Asset Store page as this helps us continue to provide updates and support to our users. ",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            GUILayout.Label(
                "If you have any questions or concerns please do not hesitate to get in touch with us via email or the Unity forums.",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            SRInternalEditorUtil.DrawFooterLayout(position.width - 15);

            EditorGUILayout.EndScrollView();

            Repaint();
        }
コード例 #8
0
        private void DrawBugReportSignupForm(Settings settings)
        {
            var isWeb = false;

#if UNITY_WEBPLAYER
            EditorGUILayout.HelpBox("Signup form is not available when build target is Web Player.", MessageType.Error);
            isWeb = true;
#endif

            EditorGUI.BeginDisabledGroup(isWeb || !_enableTabChange);

            GUILayout.Label("Signup Form", SRInternalEditorUtil.Styles.HeaderLabel);
            GUILayout.Label(
                "SRDebugger requires a free API key to enable the bug reporter system. This form will acquire one for you.",
                SRInternalEditorUtil.Styles.ParagraphLabel);

            if (
                SRInternalEditorUtil.ClickableLabel(
                    "Already got an API key? <color={0}>Click here</color>.".Fmt(SRInternalEditorUtil.Styles.LinkColour),
                    SRInternalEditorUtil.Styles.RichTextLabel))
            {
                _showBugReportSignupForm = false;
                Repaint();
            }

            EditorGUILayout.Space();

            GUILayout.Label("Invoice/Order Number", EditorStyles.boldLabel);

            GUILayout.Label(
                "Enter the order number from your Asset Store purchase email.",
                EditorStyles.miniLabel);

            _invoiceNumber = EditorGUILayout.TextField(_invoiceNumber);

            EditorGUILayout.Space();

            GUILayout.Label("Email Address", EditorStyles.boldLabel);

            GUILayout.Label(
                "Provide an email address where the bug reports should be sent.",
                EditorStyles.miniLabel);

            _emailAddress = EditorGUILayout.TextField(_emailAddress);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            if (SRInternalEditorUtil.ClickableLabel(
                    "I agree to the <color={0}>terms and conditions</color>.".Fmt(SRInternalEditorUtil.Styles.LinkColour),
                    SRInternalEditorUtil.Styles.RichTextLabel))
            {
                ApiSignupTermsWindow.Open();
            }

            _agreeLegal = EditorGUILayout.Toggle(_agreeLegal);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            var isEnabled = !string.IsNullOrEmpty(_invoiceNumber) && !string.IsNullOrEmpty(_emailAddress) && _agreeLegal;
            EditorGUI.BeginDisabledGroup(!isEnabled);

            if (GUILayout.Button("Submit"))
            {
                _errorMessage    = null;
                _enableTabChange = false;

                EditorApplication.delayCall += () =>
                {
                    ApiSignup.SignUp(_emailAddress, _invoiceNumber,
                                     (success, key, email, error) => OnSignupResult(success, key, email, error, settings));
                    Repaint();
                };
            }

            EditorGUI.EndDisabledGroup();

            if (!string.IsNullOrEmpty(_errorMessage))
            {
                EditorGUILayout.HelpBox(_errorMessage, MessageType.Error, true);
            }

            GUILayout.FlexibleSpace();

            GUILayout.Label("Having trouble? Please email [email protected] for assistance.",
                            EditorStyles.miniLabel);

            EditorGUI.EndDisabledGroup();
        }
コード例 #9
0
        private void DrawTabLayout(Settings settings)
        {
            GUILayout.Label("Pinned Tool Positions", SRInternalEditorUtil.Styles.HeaderLabel);

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            var rect = GUILayoutUtility.GetRect(360, 210);

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            SRInternalEditorUtil.DrawLayoutPreview(rect, settings);

            EditorGUILayout.BeginHorizontal();

            {
                EditorGUILayout.BeginVertical();

                GUILayout.Label("Console", SRInternalEditorUtil.Styles.InspectorHeaderStyle);

                settings.ConsoleAlignment =
                    (ConsoleAlignment)EditorGUILayout.EnumPopup(settings.ConsoleAlignment);

                EditorGUILayout.EndVertical();
            }

            {
                EditorGUI.BeginDisabledGroup(settings.EnableTrigger == Settings.TriggerEnableModes.Off);

                EditorGUILayout.BeginVertical();

                GUILayout.Label("Entry Trigger", SRInternalEditorUtil.Styles.InspectorHeaderStyle);

                settings.TriggerPosition =
                    (PinAlignment)EditorGUILayout.EnumPopup(settings.TriggerPosition);

                EditorGUILayout.EndVertical();

                EditorGUI.EndDisabledGroup();
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            {
                EditorGUILayout.BeginVertical();

                GUILayout.Label("Profiler", SRInternalEditorUtil.Styles.InspectorHeaderStyle);

                settings.ProfilerAlignment =
                    (PinAlignment)EditorGUILayout.EnumPopup((ProfilerAlignment)settings.ProfilerAlignment);

                EditorGUILayout.EndVertical();
            }

            {
                EditorGUILayout.BeginVertical();

                GUILayout.Label("Options", SRInternalEditorUtil.Styles.InspectorHeaderStyle);

                settings.OptionsAlignment =
                    (PinAlignment)EditorGUILayout.EnumPopup((OptionsAlignment)settings.OptionsAlignment);

                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndHorizontal();

            // Expand content area to fit all available space
            GUILayout.FlexibleSpace();
        }
コード例 #10
0
        private void OnGUI()
        {
            // Draw header area
            SRInternalEditorUtil.BeginDrawBackground();
            SRInternalEditorUtil.DrawLogo(SRInternalEditorUtil.GetLogo());
            SRInternalEditorUtil.EndDrawBackground();

            // Draw header/content divider
            EditorGUILayout.BeginVertical(SRInternalEditorUtil.Styles.SettingsHeaderBoxStyle);
            EditorGUILayout.EndVertical();

            Settings settings;

            if (!SettingsReady(out settings))
            {
                return;
            }

            // Draw tab buttons
            var rect = EditorGUILayout.BeginVertical(GUI.skin.box);

            --rect.width;
            var height = 18;

            EditorGUI.BeginChangeCheck();
            EditorGUI.BeginDisabledGroup(!_enableTabChange);

            for (var i = 0; i < _tabs.Length; ++i)
            {
                var xStart = Mathf.RoundToInt(i * rect.width / _tabs.Length);
                var xEnd   = Mathf.RoundToInt((i + 1) * rect.width / _tabs.Length);

                var pos = new Rect(rect.x + xStart, rect.y, xEnd - xStart, height);

                if (GUI.Toggle(pos, (int)_selectedTab == i, new GUIContent(_tabs[i]), EditorStyles.toolbarButton))
                {
                    _selectedTab = (Tabs)i;
                }
            }

            GUILayoutUtility.GetRect(10f, height);

            EditorGUI.EndDisabledGroup();

            if (EditorGUI.EndChangeCheck())
            {
                _scrollPosition            = Vector2.zero;
                GUIUtility.keyboardControl = 0;
            }

            // Draw selected tab

            switch (_selectedTab)
            {
            case Tabs.General:
                DrawTabGeneral(settings);
                break;

            case Tabs.Layout:
                DrawTabLayout(settings);
                break;

            case Tabs.Bug_Reporter:
                DrawTabBugReporter(settings);
                break;

            case Tabs.Shortcuts:
                DrawTabShortcuts(settings);
                break;

            case Tabs.Advanced:
                DrawTabAdvanced(settings);
                break;
            }

            EditorGUILayout.EndVertical();

            // Display rating prompt and link buttons

            EditorGUILayout.LabelField(SRDebugEditorStrings.Current.SettingsRateBoxContents, EditorStyles.miniLabel);

            SRInternalEditorUtil.DrawFooterLayout(position.width);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(settings);
            }
        }
コード例 #11
0
ファイル: SRIntegrityCheckWindow.cs プロジェクト: malering/ET
        private void OnGUI()
        {
            // Draw header area
            SRInternalEditorUtil.BeginDrawBackground();
            SRInternalEditorUtil.DrawLogo(SRInternalEditorUtil.GetLogo());
            SRInternalEditorUtil.EndDrawBackground();

            // Draw header/content divider
            EditorGUILayout.BeginVertical(SRInternalEditorUtil.Styles.SettingsHeaderBoxStyle);
            EditorGUILayout.EndVertical();

            GUILayout.Label(
                "SRDebugger automatically scans your project to find common issues with the SRDebugger installation.");

            EditorGUILayout.Space();

            // TODO: Enable button when there are some more 'expensive' integrity checks. For now no point as alt the checks are really quick
            if (GUILayout.Button("Refresh"))
            {
                RefreshIntegrityCheck();
            }

            if (_applyingFix)
            {
                if (!EditorApplication.isCompiling && !EditorApplication.isUpdating)
                {
                    _applyingFix = false;
                    RefreshIntegrityCheck();
                }

                EditorGUI.BeginDisabledGroup(_applyingFix);
            }

            EditorGUILayout.Space();

            if (_results == null)
            {
                _results = new List <IntegrityIssue>();
            }

            EditorGUILayout.TextArea("Issues Detected: " + _results.Count, EditorStyles.boldLabel);

            EditorGUILayout.Separator();

            EditorGUILayout.Space();

            if (_results.Count == 0)
            {
                EditorGUILayout.HelpBox("No issues have been found!", MessageType.None);
            }
            else
            {
                EditorGUILayout.HelpBox("It is highly recommended to backup your project before using this tool.", MessageType.Warning);

                _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, false,
                                                            GUILayout.Width(position.width));

                DrawIssuesList();

                EditorGUILayout.EndScrollView();
            }

            if (_applyingFix)
            {
                EditorGUI.EndDisabledGroup();
            }
        }
コード例 #12
0
ファイル: SRInternalEditorUtil.cs プロジェクト: malering/ET
            private static SettingsResult InternalTryGetOrCreateSettings(out Settings instance, out string message)
            {
                instance = null;
                message  = null;

                if (EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    message = "Settings can only be modified while in edit-mode. Exit play mode to make changes to SRDebugger settings.";
                    return(SettingsResult.Waiting);
                }

                // If compiling, wait for that to finish. We might be disabling/enabling SRDebugger and don't want to recreate the settings while that is in progress.
                if (EditorApplication.isCompiling || EditorApplication.isUpdating)
                {
                    message = "Waiting for Unity to finish compiling/updating...";
                    return(SettingsResult.Waiting);
                }

                // Check if there is a 'disabled' settings file, we don't want to create a new settings file if a disabled one exists.
                string disabledSettingsFile = SRInternalEditorUtil.GetAssetPath(DisabledSettingsFilePath);

                if (File.Exists(disabledSettingsFile))
                {
                    message = "A settings file already exists but is disabled. Please ensure SRDebugger is correctly enabled or disabled.";
                    return(SettingsResult.Error);
                }

                // Get resources folder path
                var settingsAssetPath = SRInternalEditorUtil.GetAssetPath(SettingsFilePath);

                // Load existing asset.
                if (File.Exists(settingsAssetPath))
                {
                    instance = AssetDatabase.LoadAssetAtPath <Settings>(settingsAssetPath);

                    if (instance == null)
                    {
                        message = "Error loading settings asset.";
                        return(SettingsResult.Error);
                    }

                    return(SettingsResult.Loaded);
                }

                Debug.Log("[SRDebugger] Creating settings asset at {0}".Fmt(settingsAssetPath));

                instance = ScriptableObject.CreateInstance <Settings>();

                string containingDirectory = Path.GetDirectoryName(settingsAssetPath);

                if (containingDirectory == null)
                {
                    message = "Error finding target settings directory.";
                    return(SettingsResult.Error);
                }

                // Create directory if it doesn't exist
                Directory.CreateDirectory(containingDirectory);

                // Save instance if in editor
                AssetDatabase.CreateAsset(instance, settingsAssetPath);

                return(SettingsResult.Loaded);
            }
コード例 #13
0
 static void ForceRecompile()
 {
     AssetDatabase.ImportAsset(SRInternalEditorUtil.GetAssetPath("StompyRobot.SRDebugger.asmdef"), ImportAssetOptions.ForceUpdate);
 }