Skip to content

Commit b69812d

Browse files
committed
Adds a "suppress startup window" option, fixes inksettings never being unloaded
1 parent 5d52dc4 commit b69812d

File tree

7 files changed

+85
-17
lines changed

7 files changed

+85
-17
lines changed

Packages/Ink/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG.md
22

3+
## Version 1.1.4 (1st December 2022):
4+
- Adds InkSettings.suppressStartupWindow, which can be used to prevent this window from appearing (requested for some CI/CD pipelines).
5+
- Adds links to Discord for community support in help menu, startup window and setting menu.
6+
- Fixes an issue where InkSettings ScriptableObjects wouldn't be unloaded.
7+
38
## Version 1.1.1 (20th October 2022):
49
- Updates ink to 1.1.1.
510
- The InkCompiler.OnCompileInk event now fires once when the compilation stack completes and returns an array of compiled files

Packages/Ink/Editor/Core/Ink Library/InkLibrary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class InkLibrary : ScriptableObject, IEnumerable<InkFile> {
2121
#endif
2222
// Ink version. This should really come from the core ink code.
2323
public static System.Version inkVersionCurrent = new System.Version(1,1,1);
24-
public static System.Version unityIntegrationVersionCurrent = new System.Version(1,1,3);
24+
public static System.Version unityIntegrationVersionCurrent = new System.Version(1,1,4);
2525

2626
static string absoluteSavePath {
2727
get {

Packages/Ink/Editor/Core/Ink Settings/InkSettings.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public static InkSettings instance {
4646
instance = ScriptableObject.CreateInstance<InkSettings>();
4747
instance.Save(true);
4848
}
49+
// Oh gosh Unity never unloads ScriptableObjects once created! This fixes it but is more of an expensive call than I like.
50+
// I've commented this out in favour of a callback approach - see OnEnable. Left this for posterity in case we need to return to this.
51+
// foreach (var settings in Resources.FindObjectsOfTypeAll<InkSettings>()) {
52+
// if(settings == instance) continue;
53+
// DestroyImmediate(settings);
54+
// }
4955
}
5056
return _instance;
5157
} private set {
@@ -84,6 +90,8 @@ public string templateFilePath {
8490
public int compileTimeout = 30;
8591

8692
public bool printInkLogsInConsoleOnCompile;
93+
94+
public bool suppressStartupWindow;
8795

8896
#if UNITY_EDITOR && !UNITY_2018_1_OR_NEWER
8997
[MenuItem("Edit/Project Settings/Ink", false, 500)]
@@ -102,6 +110,10 @@ public bool ShouldCompileInkFileAutomatically (InkFile inkFile) {
102110

103111

104112
void OnEnable () {
113+
// Oh gosh Unity never unloads ScriptableObjects once created! We destroy these objects before we recompile so there's only ever one in memory at once.
114+
AssemblyReloadEvents.beforeAssemblyReload += () => {
115+
DestroyImmediate(this);
116+
};
105117
// Validate the includeFilesToCompileAsMasterFiles list.
106118
for (int i = includeFilesToCompileAsMasterFiles.Count - 1; i >= 0; i--) {
107119
if(includeFilesToCompileAsMasterFiles[i] == null) {
@@ -115,7 +127,7 @@ void OnEnable () {
115127
filesToCompileAutomatically.RemoveAt(i);
116128
}
117129
}
118-
// Deletes the persistent version of this asset that we used to use prior to 0.9.71
130+
// Deletes the persistent version of this asset that we used to use prior to 0.9.71
119131
if(!Application.isPlaying && EditorUtility.IsPersistent(this)) {
120132
var path = AssetDatabase.GetAssetPath(this);
121133
if(!string.IsNullOrEmpty(path)) {

Packages/Ink/Editor/Core/Ink Settings/InkSettingsEditor.cs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ public override void OnInspectorGUI() {
1919

2020
DrawSettings(serializedObject);
2121

22-
if(GUI.changed && target != null)
22+
if (GUI.changed && target != null) {
2323
EditorUtility.SetDirty(target);
24+
((InkSettings) target).Save(true);
25+
}
2426
serializedObject.ApplyModifiedProperties();
2527
}
2628

@@ -47,7 +49,9 @@ public static SettingsProvider CreateInkSettingsProvider() {
4749
#endif
4850

4951
static void DrawSettings (InkSettings settings) {
50-
EditorGUI.indentLevel++;
52+
EditorGUI.BeginChangeCheck();
53+
54+
EditorGUI.indentLevel++;
5155
DrawVersions();
5256
EditorGUILayout.Separator();
5357

@@ -57,19 +61,29 @@ static void DrawSettings (InkSettings settings) {
5761
EditorGUILayout.LabelField(new GUIContent("Settings"), EditorStyles.boldLabel);
5862
if(settings.templateFile == null)
5963
DrawTemplateMissingWarning();
60-
settings.templateFile = (DefaultAsset)EditorGUILayout.ObjectField(new GUIContent("Ink Template", "Optional. The default content of files created via Assets > Create > Ink."), settings.templateFile, typeof(DefaultAsset));
64+
settings.templateFile = (DefaultAsset)EditorGUILayout.ObjectField(new GUIContent("Ink Template", "Optional. The default content of files created via Assets > Create > Ink."), settings.templateFile, typeof(DefaultAsset));
6165

6266
settings.defaultJsonAssetPath = (DefaultAsset)EditorGUILayout.ObjectField(new GUIContent("New JSON Path", "By default, story JSON files are placed next to the ink. Drag a folder here to place new JSON files there instead."), settings.defaultJsonAssetPath, typeof(DefaultAsset));
6367
settings.compileAllFilesAutomatically = EditorGUILayout.Toggle(new GUIContent("Compile All Ink Automatically", "When disabled, automatic compilation can be enabled on a per-story basis via the inspector for a master story file. This can be helpful when you have several stories in a single project."), settings.compileAllFilesAutomatically);
6468
settings.delayInPlayMode = EditorGUILayout.Toggle(new GUIContent("Delay compilation if in Play Mode", "When enabled, ink compilation is delayed if in play mode. Files will be compiled on re-entering edit mode."), settings.delayInPlayMode);
6569
settings.printInkLogsInConsoleOnCompile = EditorGUILayout.Toggle(new GUIContent("Print ink TODOs in console on compile", "When enabled, ink lines starting with TODO are printed in the console."), settings.printInkLogsInConsoleOnCompile);
6670
settings.handleJSONFilesAutomatically = EditorGUILayout.Toggle(new GUIContent("Handle JSON Automatically", "Whether JSON files are moved, renamed and deleted along with their ink files."), settings.handleJSONFilesAutomatically);
6771
settings.compileTimeout = EditorGUILayout.IntField(new GUIContent("Compile Timeout", "The max time the compiler will attempt to compile for in case of unhanded errors. You may need to increase this for very large ink projects."), settings.compileTimeout);
72+
settings.suppressStartupWindow = EditorGUILayout.Toggle(new GUIContent("Suppress Startup Window", "Prevent the \"what's new\" (the one that appears if you click the \"Show changelog\" button above) appearing when the version of this plugin has changed and Unity is opened. This can be useful for CI/CD pipelines, where auto-launching editor windows can fail to load due to a Unity bug."), settings.suppressStartupWindow);
6873

6974
EditorGUIUtility.labelWidth = cachedLabelWidth;
75+
76+
EditorGUILayout.Separator();
77+
DrawRequestButton();
7078

7179
EditorGUI.indentLevel--;
80+
81+
if (EditorGUI.EndChangeCheck()) {
82+
EditorUtility.SetDirty(settings);
83+
settings.Save(true);
84+
}
7285
}
86+
7387
static void DrawSettings (SerializedObject settings) {
7488
DrawVersions();
7589
EditorGUILayout.Separator();
@@ -89,11 +103,15 @@ static void DrawSettings (SerializedObject settings) {
89103
EditorGUILayout.PropertyField(settings.FindProperty("printInkLogsInConsoleOnCompile"), new GUIContent("Print ink TODOs in console on compile", "When enabled, ink lines starting with TODO are printed in the console."));
90104
EditorGUILayout.PropertyField(settings.FindProperty("handleJSONFilesAutomatically"), new GUIContent("Handle JSON Automatically", "Whether JSON files are moved, renamed and deleted along with their ink files."));
91105
EditorGUILayout.PropertyField(settings.FindProperty("compileTimeout"), new GUIContent("Compile Timeout", "The max time the compiler will attempt to compile for in case of unhanded errors. You may need to increase this for very large ink projects."));
106+
EditorGUILayout.PropertyField(settings.FindProperty("suppressStartupWindow"), new GUIContent("Suppress Startup Window", "Prevent the \"what's new\" (the one that appears if you click the \"Show changelog\" button above) appearing when the version of this plugin has changed and Unity is opened. This can be useful for CI/CD pipelines, where auto-launching editor windows can fail to load due to a Unity bug."));
92107

93108
if(EditorGUI.EndChangeCheck()) {
94109
settings.ApplyModifiedProperties();
95-
}
110+
}
96111
EditorGUIUtility.labelWidth = cachedLabelWidth;
112+
113+
EditorGUILayout.Separator();
114+
DrawRequestButton();
97115
}
98116

99117

@@ -105,9 +123,25 @@ static void DrawVersions () {
105123
EditorGUILayout.TextField(new GUIContent("Ink story format version", "Significant changes to the Ink runtime are recorded by the story format version.\nCompatibility between different versions is limited; see comments at Ink.Runtime.Story.inkVersionCurrent for more details."), Ink.Runtime.Story.inkVersionCurrent.ToString());
106124
EditorGUILayout.TextField(new GUIContent("Ink save format version", "Version of the ink save/load system.\nCompatibility between different versions is limited; see comments at Ink.Runtime.StoryState.kInkSaveStateVersion for more details."), Ink.Runtime.StoryState.kInkSaveStateVersion.ToString());
107125
EditorGUI.EndDisabledGroup();
108-
if(GUILayout.Button("Show changelog")) {
109-
InkUnityIntegrationStartupWindow.ShowWindow();
126+
if (GUILayout.Button("Show changelog", GUILayout.Width(140))) {
127+
InkUnityIntegrationStartupWindow.ShowWindow();
128+
}
129+
}
130+
131+
static void DrawRequestButton() {
132+
EditorGUILayout.LabelField(new GUIContent("Support + Requests"), EditorStyles.boldLabel);
133+
134+
EditorGUILayout.LabelField("Is there a setting you'd like? Or a feature you'd like to request?");
135+
// EditorGUILayout.BeginVertical(GUILayout.Width(220));
136+
EditorGUILayout.BeginHorizontal();
137+
if(GUILayout.Button("Reach us on Discord", GUILayout.Width(220))) {
138+
Application.OpenURL("https://discord.gg/inkle");
139+
}
140+
if(GUILayout.Button("Submit an issue on GitHub", GUILayout.Width(220))) {
141+
Application.OpenURL("https://github.com/inkle/ink-unity-integration/issues/new");
110142
}
143+
EditorGUILayout.EndHorizontal();
144+
// EditorGUILayout.EndVertical();
111145
}
112146

113147
static void DrawTemplateMissingWarning () {

Packages/Ink/Editor/Core/InkEditorUtils.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ public static void OpenAPIDocumentation() {
133133
Application.OpenURL("https://github.com/inkle/ink/blob/master/Documentation/RunningYourInk.md");
134134
}
135135

136+
[MenuItem("Help/Ink/Discord (Community + Support...")]
137+
public static void OpenDiscord() {
138+
Application.OpenURL("https://discord.gg/inkle");
139+
}
140+
136141
[MenuItem("Help/Ink/Donate...")]
137142
public static void Donate() {
138143
Application.OpenURL("https://www.patreon.com/inkle");

Packages/Ink/Editor/Tools/Startup Window/InkUnityIntegrationStartupWindow.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ public class InkUnityIntegrationStartupWindow : EditorWindow {
1111
static int announcementVersionPreviouslySeen;
1212

1313
static InkUnityIntegrationStartupWindow () {
14-
UnityEditor.EditorApplication.delayCall += TryCreateWindow;
14+
UnityEditor.EditorApplication.delayCall += TryCreateWindow;
1515
}
1616

1717
static void TryCreateWindow() {
18+
if (InkSettings.instance.suppressStartupWindow) return;
1819
announcementVersionPreviouslySeen = EditorPrefs.GetInt(editorPrefsKeyForVersionSeen, -1);
1920
if(announcementVersion != announcementVersionPreviouslySeen) {
2021
ShowWindow();
@@ -60,6 +61,9 @@ void OnGUI ()
6061
if (GUILayout.Button("❤️Support Us!❤️")) {
6162
Application.OpenURL("https://www.patreon.com/inkle");
6263
}
64+
if (GUILayout.Button("Discord Community+Support")) {
65+
Application.OpenURL("https://discord.gg/inkle");
66+
}
6367
if (GUILayout.Button("Close")) {
6468
Close();
6569
}
@@ -71,16 +75,23 @@ void OnGUI ()
7175
{
7276
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
7377
{
74-
78+
// 1.1.4
79+
EditorGUILayout.BeginVertical(GUI.skin.box);
80+
EditorGUILayout.LabelField("Version 1.1.4:", EditorStyles.boldLabel);
81+
EditorGUILayout.LabelField("• Adds InkSettings.suppressStartupWindow, which can be used to prevent this window from appearing (requested for some CI/CD pipelines).", EditorStyles.wordWrappedLabel);
82+
EditorGUILayout.LabelField("• Adds links to Discord for community support in help menu, startup window and setting menu.", EditorStyles.wordWrappedLabel);
83+
EditorGUILayout.LabelField("• Fixes an issue where InkSettings ScriptableObjects wouldn't be unloaded.", EditorStyles.wordWrappedLabel);
84+
EditorGUILayout.EndVertical();
7585
// 1.1.1
7686
EditorGUILayout.BeginVertical(GUI.skin.box);
77-
EditorGUILayout.LabelField("Updates ink to 1.1.1.", EditorStyles.boldLabel);
78-
EditorGUILayout.LabelField("The InkCompiler.OnCompileInk event now fires once when the compilation stack completes and returns an array of compiled files", EditorStyles.wordWrappedLabel);
79-
EditorGUILayout.LabelField("Fixes some async threading issues when compiling", EditorStyles.wordWrappedLabel);
80-
EditorGUILayout.LabelField("Adds JSON formatting for save states copied or saved via the Ink Player Window", EditorStyles.wordWrappedLabel);
81-
EditorGUILayout.LabelField("Use the Unity Progress API to show compilation. Useful for large ink projects!", EditorStyles.wordWrappedLabel);
82-
EditorGUILayout.LabelField("Included files now show their own included files in the Inspector", EditorStyles.wordWrappedLabel);
83-
EditorGUILayout.LabelField("Various optimisations", EditorStyles.wordWrappedLabel);
87+
EditorGUILayout.LabelField("Version 1.1.1:", EditorStyles.boldLabel);
88+
EditorGUILayout.LabelField("• Updates ink to 1.1.1.", EditorStyles.wordWrappedLabel);
89+
EditorGUILayout.LabelField("• The InkCompiler.OnCompileInk event now fires once when the compilation stack completes and returns an array of compiled files", EditorStyles.wordWrappedLabel);
90+
EditorGUILayout.LabelField("• Fixes some async threading issues when compiling", EditorStyles.wordWrappedLabel);
91+
EditorGUILayout.LabelField("• Adds JSON formatting for save states copied or saved via the Ink Player Window", EditorStyles.wordWrappedLabel);
92+
EditorGUILayout.LabelField("• Use the Unity Progress API to show compilation. Useful for large ink projects!", EditorStyles.wordWrappedLabel);
93+
EditorGUILayout.LabelField("• Included files now show their own included files in the Inspector", EditorStyles.wordWrappedLabel);
94+
EditorGUILayout.LabelField("• Various optimisations", EditorStyles.wordWrappedLabel);
8495
EditorGUILayout.EndVertical();
8596
// 1.0.2
8697
EditorGUILayout.BeginVertical(GUI.skin.box);

ProjectSettings/InkSettings.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ MonoBehaviour:
2424
handleJSONFilesAutomatically: 1
2525
compileTimeout: 30
2626
printInkLogsInConsoleOnCompile: 0
27+
suppressStartupWindow: 0

0 commit comments

Comments
 (0)