-
-
Notifications
You must be signed in to change notification settings - Fork 58
Getting started window on installation #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| using System.Linq; | ||
| using System.Threading; | ||
| using UnityEditor; | ||
| using UnityEditor.PackageManager; | ||
| using UnityEngine; | ||
|
|
||
| namespace Sentry.Unity.Editor | ||
| { | ||
| public class SentryAssetPostprocessor : AssetPostprocessor | ||
| { | ||
| private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) | ||
| { | ||
| var imported = importedAssets.Any(path => path.StartsWith("Packages/")); | ||
| var deleted = deletedAssets.Any(path => path.StartsWith("Packages/")); | ||
|
|
||
| if (imported || deleted) | ||
| { | ||
| InitializeOnLoad(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Instead of hooking into AssetPostprocessing we could InitializeOnLoad | ||
| * But this gets called on domain reload (i.e. enter playmode) and could be disabled by the user. | ||
| */ | ||
| // [InitializeOnLoadMethod] | ||
| private static void InitializeOnLoad() | ||
| { | ||
| // ASYNC! Fetching all packages the current project depends on | ||
| var listRequest = Client.List(true); | ||
| while (!listRequest.IsCompleted) | ||
| { | ||
| Thread.Sleep(100); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might freeze up the editor though, right? |
||
| } | ||
|
|
||
| if (listRequest.Error != null) | ||
| { | ||
| Debug.Log("Error: " + listRequest.Error.message); | ||
| return; | ||
| } | ||
|
|
||
| var packages = listRequest.Result; | ||
| foreach (var package in packages) | ||
| { | ||
| if (package.name.StartsWith("io.sentry")) | ||
| { | ||
| SentryGettingStartedWindow.OpenWindow(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using UnityEditor; | ||
| using UnityEngine; | ||
|
|
||
| namespace Sentry.Unity.Editor | ||
| { | ||
| public class SentryGettingStartedWindow : EditorWindow | ||
| { | ||
| private string? _dsn; | ||
|
|
||
| [MenuItem("Tools/Sentry/Getting Started")] | ||
| public static SentryGettingStartedWindow OpenWindow() | ||
| => (SentryGettingStartedWindow)GetWindow( | ||
| typeof(SentryGettingStartedWindow), true, "Sentry Getting Started Window"); | ||
|
|
||
| private void OnGUI() | ||
| { | ||
| EditorGUILayout.Space(); | ||
|
|
||
| GUILayout.Label("All that you need to get started is to provide a DSN."); | ||
|
|
||
| EditorGUILayout.Space(); | ||
| EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray); | ||
| EditorGUILayout.Space(); | ||
|
|
||
| _dsn = EditorGUILayout.TextField( | ||
| new GUIContent("DSN", "The URL to your project inside Sentry. Get yours in Sentry, Project Settings."), | ||
| _dsn); | ||
|
|
||
| EditorGUILayout.Space(); | ||
| EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray); | ||
| EditorGUILayout.Space(); | ||
|
|
||
| if (GUILayout.Button("Enable")) | ||
| { | ||
| this.Close(); | ||
| } | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to prompt also when asset deleted? I wonder the chance of false positive here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not a prompt but maybe we should delete the assets we create too? Like link.xml and the options file?