Skip to content

Commit ab0b30f

Browse files
committed
Added settings panel.
1 parent cbf598c commit ab0b30f

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

Scripts/CustomEditor/GitMenuItems.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ private static bool ValidateDiscardAllChanges()
8787

8888
}
8989

90+
[MenuItem("Git/Reset Settings", false, PRIORITY + 100)]
91+
public static void ResetSettings()
92+
{
93+
94+
if (EditorUtility.DisplayDialog(
95+
"Reset package settings",
96+
$"Are you sure you want to reset all package settings?",
97+
"Yes",
98+
"Cancel"))
99+
{
100+
101+
GitSettings.Reset();
102+
103+
}
104+
105+
}
106+
90107
}
91108

92109
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
#if UNITY_EDITOR
4+
using System.Collections.Generic;
5+
using UnityEditor;
6+
using UnityEngine;
7+
8+
namespace CandyCoded.GitStatus
9+
{
10+
11+
public static class GitSettings
12+
{
13+
14+
private const string EDITOR_PREFS_SCOPE = "xyz.candycoded.gitstatus";
15+
16+
public static string KEY_GITPATH => $"{EDITOR_PREFS_SCOPE}_gitpath";
17+
18+
public static string DefaultGitPath => SystemInfo.operatingSystemFamily.Equals(OperatingSystemFamily.Windows)
19+
? @"C:\Program Files\Git\bin\git.exe"
20+
: "/usr/local/bin/git";
21+
22+
public static string GitPath
23+
{
24+
get => EditorPrefs.GetString(KEY_GITPATH, DefaultGitPath);
25+
set => EditorPrefs.SetString(KEY_GITPATH, value);
26+
}
27+
28+
public static void Reset()
29+
{
30+
31+
EditorPrefs.DeleteKey(KEY_GITPATH);
32+
33+
}
34+
35+
}
36+
37+
public class GitSettingsProvider : SettingsProvider
38+
{
39+
40+
public GitSettingsProvider(string path, SettingsScope scopes, IEnumerable<string> keywords = null) : base(path,
41+
scopes,
42+
keywords)
43+
{
44+
45+
}
46+
47+
public override void OnGUI(string searchContext)
48+
{
49+
50+
GitSettings.GitPath = EditorGUILayout.TextField("Git Path", GitSettings.GitPath);
51+
52+
}
53+
54+
[SettingsProvider]
55+
public static SettingsProvider CreateMyCustomSettingsProvider()
56+
{
57+
58+
return new GitSettingsProvider("CandyCoded/GitStatus", SettingsScope.Project);
59+
60+
}
61+
62+
}
63+
64+
}
65+
#endif

Scripts/CustomEditor/GitSettings.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)