Skip to content

Commit 73dffaa

Browse files
authored
Merge pull request #2 from lupidan/fix/NREIfNoSettingsFileAvailable
Fix NRE when no settings file is present
2 parents b5c6d85 + 76559c4 commit 73dffaa

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.7.0] - 2021-11-06
4+
- Fixes bug when settings file is does not exist that prevented Postprocessing to be executed successfully
5+
- Adds some info regarding the settings file created by the plugin
6+
37
## [0.6.0] - 2021-08-11
48
- Fixes **major** bug of the package not returning the actual status code.
59

@@ -12,6 +16,7 @@
1216
- Editor implementation for the feature, imitating the native implementation.
1317
- Configurable automatic postprocessing, add required frameworks and required Info.plist entries
1418

15-
[Unreleased]: https://github.com/lupidan/unity-apptrackingtransparency/compare/v0.6.0...HEAD
19+
[Unreleased]: https://github.com/lupidan/unity-apptrackingtransparency/compare/v0.7.0...HEAD
20+
[0.7.0]: https://github.com/lupidan/unity-apptrackingtransparency/compare/v0.6.0...v0.7.0
1621
[0.6.0]: https://github.com/lupidan/unity-apptrackingtransparency/compare/v0.5.0...v0.6.0
1722
[0.5.0]: https://github.com/lupidan/unity-apptrackingtransparency/releases/tag/v0.5.0

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This plugin supports the following platforms:
2727

2828
## Installation
2929

30-
> Current version is v0.6.0
30+
> Current version is v0.7.0
3131
3232
Here is a list of available options to install the plugin
3333

@@ -37,7 +37,7 @@ Just add this line to the `Packages/manifest.json` file of your Unity Project:
3737

3838
```json
3939
"dependencies": {
40-
"com.lupidan.unity-apptrackingtransparency": "https://github.com/lupidan/unity-apptrackingtransparency.git?path=/com.lupidan.unity-apptrackingtransparency#v0.6.0"
40+
"com.lupidan.unity-apptrackingtransparency": "https://github.com/lupidan/unity-apptrackingtransparency.git?path=/com.lupidan.unity-apptrackingtransparency#v0.7.0"
4141
}
4242
```
4343

@@ -126,7 +126,12 @@ In this section you can control the current status of the editor implementation
126126

127127
### iOS Build settings
128128

129-
The plugin offers automated options for post-processing on iOS.
129+
The plugin offers automated options for post-processing on iOS. The first time you modify the iOS Build Settings, settings are saved in:
130+
131+
`ProjectSettings/com.lupidan.unity-apptrackingtransparency/AppTrackingTransparencySettings.json`
132+
133+
> :warning: This is a file you will want to commit to your repository, to keep your plugin configuration saved.
134+
130135
This section allow you to configure what parts of the automatic post-processing you want to have for your project.
131136
- *Automatic postprocessing*: If enabled the automatic postprocessing for iOS will be run. If disabled, it will be completely ignored.
132137
- *Postprocessing Callback Order*: The order in which the postprocessing will be run. You can change the number so it works along other postprocessing scripts you may have in your project. The default value is 10.

com.lupidan.unity-apptrackingtransparency/Editor/AppTrackingTransparencyEditorTools.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private void OnGUI()
7777
GUILayout.Label("iOS Build Settings", EditorStyles.boldLabel);
7878
GUILayout.Space(10);
7979

80-
var settings = AppTrackingTransparencySettingsManager.LoadOrCreateSettings();
80+
var settings = AppTrackingTransparencySettingsManager.LoadSettings();
8181
GUILayout.Label("Settings file v" + settings.SettingsFileVersion, EditorStyles.miniLabel);
8282
GUILayout.Label(AppTrackingTransparencySettingsManager.PrintableProjectSettingsFilePath, EditorStyles.miniLabel);
8383

@@ -118,14 +118,15 @@ private void OnGUI()
118118
GUILayout.Label("- " + GetUserTrackingUsageDescriptionHint(), EditorStyles.miniLabel);
119119
}
120120

121-
AppTrackingTransparencySettingsManager.WriteSettings(settings);
122-
123121
GUILayout.Space(10);
124122
if (GUILayout.Button("Reset to default", new [] {GUILayout.MaxWidth(150)}))
125123
{
126124
AppTrackingTransparencySettingsManager.DeleteSettings();
127-
AppTrackingTransparencySettingsManager.LoadSettings();
125+
settings = AppTrackingTransparencySettingsManager.LoadSettings();
128126
}
127+
128+
AppTrackingTransparencySettingsManager.WriteSettings(settings);
129+
129130
EditorGUIUtility.labelWidth = labelWidth;
130131
}
131132
}

com.lupidan.unity-apptrackingtransparency/Editor/Settings/AppTrackingTransparencySettingsManager.cs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,20 @@ public static class AppTrackingTransparencySettingsManager
2424
SettingsFolderPath,
2525
DedicatedSettingsFileName);
2626

27-
public static AppTrackingTransparencySettings LoadOrCreateSettings()
28-
{
29-
var settings = LoadSettings();
30-
if (settings == null)
31-
{
32-
settings = new AppTrackingTransparencySettings();
33-
settings.SettingsFileVersion = 1;
34-
settings.AutomaticPostProcessing = true;
35-
settings.AutomaticPostProcessingCallbackOrder = 10;
36-
settings.AddAppTransparencyTrackingFramework = true;
37-
settings.AddUserTrackingUsageDescription = true;
38-
settings.UserTrackingUsageDescription = "Your data will be used to deliver personalized ads to you";
39-
settings.AutoDetectInfoPlistFilePath = true;
40-
settings.MainInfoPlistFilePath = "Info.plist";
41-
WriteSettings(settings);
42-
}
43-
44-
return settings;
45-
}
46-
4727
public static AppTrackingTransparencySettings LoadSettings()
4828
{
4929
if (!File.Exists(SettingsFilePath))
5030
{
51-
return null;
31+
var defaultSettings = new AppTrackingTransparencySettings();
32+
defaultSettings.SettingsFileVersion = 1;
33+
defaultSettings.AutomaticPostProcessing = true;
34+
defaultSettings.AutomaticPostProcessingCallbackOrder = 10;
35+
defaultSettings.AddAppTransparencyTrackingFramework = true;
36+
defaultSettings.AddUserTrackingUsageDescription = true;
37+
defaultSettings.UserTrackingUsageDescription = "Your data will be used to deliver personalized ads to you";
38+
defaultSettings.AutoDetectInfoPlistFilePath = true;
39+
defaultSettings.MainInfoPlistFilePath = "Info.plist";
40+
return defaultSettings;
5241
}
5342

5443
return JsonUtility.FromJson<AppTrackingTransparencySettings>(File.ReadAllText(SettingsFilePath));

0 commit comments

Comments
 (0)