Skip to content

Commit 142e867

Browse files
committed
Merge branch 'release/v0.2.0' into main
2 parents 39d3c86 + 5cfbd33 commit 142e867

File tree

17 files changed

+247
-104
lines changed

17 files changed

+247
-104
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# These owners will be the default owners for everything in
2+
# the repo. Unless a later match takes precedence,
3+
# @HarrisonHough, @rYuuk and @srcnalt will be requested for
4+
# review when someone opens a pull request.
5+
* @HarrisonHough @rYuuk @srcnalt
6+

.github/latest.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
This update fixes a number of bugs and adds support for optional SDK logging.
2+
3+
## Changelog
4+
5+
### Added
6+
- optional sdk logging
7+
- don't ask again option for update check
8+
9+
### Updated
10+
- PartnerSubdomainSettings refactored to a CoreSettings scriptable object
11+
12+
### Fixed
13+
- core settings asset now automatically created if it is missing.
14+
- Various bug fixes and improvements
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Automatic Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: ncipollo/release-action@v1
17+
with:
18+
name: "Ready Player Me Unity SDK: Core ${{github.ref_name}}"
19+
bodyFile: ".github/latest.md"

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [0.2.0] - 2023.02.08
7+
8+
### Added
9+
- optional sdk logging
10+
11+
### Updated
12+
- PartnerSubdomainSettings refactored to a CoreSettings scriptable object
13+
14+
### Fixed
15+
- Various bug fixes and improvements
16+
617
## [0.1.0] - 2023.01.22
718

819
### Updated

Editor/Module Management/ModuleList.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static class ModuleList
1414
name = "com.readyplayerme.core",
1515
gitUrl = "https://github.com/readyplayerme/rpm-unity-sdk-core.git",
1616
branch = "",
17-
version = "0.1.1"
17+
version = "0.2.0"
1818
};
1919

2020
/// <summary>
@@ -34,14 +34,14 @@ public static class ModuleList
3434
name = "com.readyplayerme.avatarloader",
3535
gitUrl = "https://github.com/readyplayerme/rpm-unity-sdk-avatar-loader.git",
3636
branch = "",
37-
version = "0.1.1"
37+
version = "0.2.0"
3838
},
3939
new ModuleInfo
4040
{
4141
name = "com.readyplayerme.webview",
4242
gitUrl = "https://github.com/readyplayerme/rpm-unity-sdk-webview.git",
4343
branch = "",
44-
version = "0.1.0"
44+
version = "0.2.0"
4545
}
4646
};
4747

Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,86 @@
11
using System;
22
using System.Linq;
3-
using UnityEditor;
4-
using UnityEngine;
5-
using Newtonsoft.Json;
63
using System.Threading;
7-
using UnityEngine.Networking;
84
using System.Threading.Tasks;
5+
using Newtonsoft.Json;
6+
using UnityEditor;
97
using UnityEditor.PackageManager;
10-
using UnityEditor.PackageManager.Requests;
8+
using UnityEngine;
9+
using UnityEngine.Networking;
1110
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
1211

1312
namespace ReadyPlayerMe.Core.Editor
1413
{
1514
/// <summary>
16-
/// Class <c>ModuleUpdater</c> is responsible for checking and updating the Ready Player Me SDK modules.
15+
/// It is responsible for checking and updating the Ready Player Me SDK modules.
1716
/// </summary>
18-
public static class ModuleUpdater
17+
[InitializeOnLoad]
18+
public class ModuleUpdater
1919
{
20+
private class Release
21+
{
22+
[JsonProperty("tag_name")]
23+
public string Tag;
24+
}
25+
2026
private const string PACKAGE_JSON = "package.json";
2127
private const string PACKAGE_DOMAIN = "com.readyplayerme";
2228

2329
private const string GITHUB_WEBSITE = "https://github.com";
2430
private const string GITHUB_API_URL = "https://api.github.com/repos";
2531

26-
private const string WARNING_PACKAGES_NOT_FOUND = "No Ready Player Me packages found.";
27-
private const string WARNING_UPDATE_SKIPPED = "No Ready Player Me packages found.";
2832
private const int MILLISECONDS_TIMEOUT = 20;
2933
private const string ASSET_FILTER = "package";
3034

35+
private const string DONT_ASK = "Dont Ask";
36+
37+
static ModuleUpdater()
38+
{
39+
EntryPoint.Startup += () => Check(true);
40+
}
41+
3142
/// <summary>
32-
/// Check for Ready Player Me package updates.
43+
/// Check for Ready Player Me package updates.
3344
/// </summary>
3445
[MenuItem("Ready Player Me/Check For Updates")]
3546
public static void CheckForUpdates()
47+
{
48+
Check();
49+
}
50+
51+
private static void Check(bool isStartup = false)
3652
{
3753
// Get PackageInfo array from RPM Module package.json files
38-
PackageInfo[] packages = AssetDatabase.FindAssets(ASSET_FILTER)
54+
var packages = AssetDatabase.FindAssets(ASSET_FILTER)
3955
.Select(AssetDatabase.GUIDToAssetPath)
4056
.Where(x => x.Contains(PACKAGE_JSON) && x.Contains(PACKAGE_DOMAIN))
4157
.Select(PackageInfo.FindForAssetPath)
4258
.ToArray();
4359

60+
if (packages.Length == 0)
61+
{
62+
Debug.Log("No rpm package found");
63+
}
64+
4465
// Turn package_name@repo_url#branch_name into https://api.github.com/repos/readyplayerme/repo_name/releases
45-
foreach (PackageInfo package in packages)
66+
foreach (var package in packages)
4667
{
4768
var repoUrl = package.packageId.Split('@')[1];
48-
var releasesUrl = repoUrl.Replace(GITHUB_WEBSITE, GITHUB_API_URL)
49-
.Split(new[] { ".git#" }, StringSplitOptions.None)[0] + "/releases";
69+
var releasesUrl = repoUrl
70+
.Split(new[] { ".git" }, StringSplitOptions.None)[0]
71+
.Replace(GITHUB_WEBSITE, GITHUB_API_URL) + "/releases";
72+
73+
5074
var packageUrl = repoUrl.Split('#')[0];
5175

5276
// Experimental or prerelease packages might look like 0.1.0-exp.1, remove after dash to parse with Version
5377
var version = package.version.Split('-')[0];
78+
79+
if (isStartup && EditorPrefs.GetBool(DONT_ASK + "-" + package.name))
80+
{
81+
continue;
82+
}
83+
5484
FetchReleases(package.name, packageUrl, releasesUrl, new Version(version));
5585
}
5686
}
@@ -65,18 +95,17 @@ public static void CheckForUpdates()
6595
private static async void FetchReleases(string packageName, string packageUrl, string releasesUrl,
6696
Version currentVersion)
6797
{
68-
UnityWebRequest request = UnityWebRequest.Get(releasesUrl);
69-
UnityWebRequestAsyncOperation op = request.SendWebRequest();
98+
var request = UnityWebRequest.Get(releasesUrl);
99+
var op = request.SendWebRequest();
70100
while (!op.isDone) await Task.Yield();
71101

72102
if (request.result == UnityWebRequest.Result.Success)
73103
{
74104
var response = request.downloadHandler.text;
75-
Release[] releases = JsonConvert.DeserializeObject<Release[]>(response);
76-
77-
Version[] versions = releases.Select(r => new Version(r.Tag.Substring(1).Split('-')[0])).ToArray();
105+
var releases = JsonConvert.DeserializeObject<Release[]>(response);
106+
var versions = releases!.Select(r => new Version(r.Tag.Substring(1).Split('-')[0])).ToArray();
78107

79-
Version latestVersion = versions.Max();
108+
var latestVersion = versions.Max();
80109

81110
if (latestVersion > currentVersion)
82111
{
@@ -99,20 +128,27 @@ private static async void FetchReleases(string packageName, string packageUrl, s
99128
private static void DisplayUpdateDialog(string packageName, Version currentVersion, Version latestVersion,
100129
string packageUrl)
101130
{
102-
var shouldUpdate = EditorUtility.DisplayDialog("Update Packages",
131+
var shouldUpdate = EditorUtility.DisplayDialogComplex("Update Packages",
103132
$"New update available for {packageName}\nCurrent version: {currentVersion}\nLatest version: {latestVersion}",
104133
"Update",
105-
"Skip");
134+
"Cancel",
135+
"Don't ask");
106136

107-
if (shouldUpdate)
108-
{
109-
packageUrl += "#v" + latestVersion;
110-
UpdateModule(packageName, packageUrl, currentVersion, latestVersion);
111-
}
112-
else
137+
switch (shouldUpdate)
113138
{
114-
// TODO: Bring analytics here
115-
Debug.LogWarning(WARNING_UPDATE_SKIPPED);
139+
// Update
140+
case 0:
141+
packageUrl += "#v" + latestVersion;
142+
UpdateModule(packageName, packageUrl, currentVersion, latestVersion);
143+
break;
144+
// Cancel
145+
case 1:
146+
// Do nothing
147+
break;
148+
// Don't ask
149+
case 2:
150+
EditorPrefs.SetBool(DONT_ASK + "-" + packageName, true);
151+
break;
116152
}
117153
}
118154

@@ -125,19 +161,13 @@ private static void DisplayUpdateDialog(string packageName, Version currentVersi
125161
/// <param name="latest">The new version of the package.</param>
126162
private static void UpdateModule(string name, string url, Version current, Version latest)
127163
{
128-
RemoveRequest removeRequest = Client.Remove(name);
164+
var removeRequest = Client.Remove(name);
129165
while (!removeRequest.IsCompleted) Thread.Sleep(MILLISECONDS_TIMEOUT);
130166

131-
AddRequest addRequest = Client.Add(url);
167+
var addRequest = Client.Add(url);
132168
while (!addRequest.IsCompleted) Thread.Sleep(MILLISECONDS_TIMEOUT);
133169

134170
Debug.Log($"Updated {name} from v{current} to v{latest}");
135171
}
136172
}
137-
138-
internal class Release
139-
{
140-
[JsonProperty("tag_name")]
141-
public string Tag;
142-
}
143173
}

Editor/Utils/EditorAssetGenerator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ namespace ReadyPlayerMe.Core.Editor
77
public static class EditorAssetGenerator
88
{
99
private const string SETTINGS_SAVE_FOLDER = "Ready Player Me/Resources/Settings";
10-
private const string PARTNER_SUB_DOMAIN_ASSET_NAME = "PartnerSubdomainSettings.asset";
10+
private const string CORE_SETTINGS_ASSET_NAME = "CoreSettings.asset";
1111

1212
public static void CreateSettingsAssets()
1313
{
1414
DirectoryUtility.ValidateDirectory($"{Application.dataPath}/{SETTINGS_SAVE_FOLDER}");
1515
AssetDatabase.Refresh();
16-
CreatePartnerSubdomainSetting();
16+
CreateCoreSettings();
1717
}
1818

19-
private static void CreatePartnerSubdomainSetting()
19+
private static void CreateCoreSettings()
2020
{
21-
var partnerSubdomainSettings = ScriptableObject.CreateInstance<PartnerSubdomainSettings>();
22-
partnerSubdomainSettings.Subdomain = "demo";
21+
var coreSettings = ScriptableObject.CreateInstance<CoreSettings>();
22+
coreSettings.Subdomain = "demo";
2323

24-
AssetDatabase.CreateAsset(partnerSubdomainSettings, $"Assets/{SETTINGS_SAVE_FOLDER}/{PARTNER_SUB_DOMAIN_ASSET_NAME}");
24+
AssetDatabase.CreateAsset(coreSettings, $"Assets/{SETTINGS_SAVE_FOLDER}/{CORE_SETTINGS_ASSET_NAME}");
2525
AssetDatabase.SaveAssets();
2626
AssetDatabase.Refresh();
2727
}

LICENSE.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
MIT License
1+
The MIT License (MIT)
2+
=====================
23

3-
Copyright (c) 2022 Ready Player Me
4+
Copyright © 2022 Ready Player Me
45

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the “Software”), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
1114

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
1417

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
18+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

Runtime/ApplicationData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static class ApplicationData
1414
static ApplicationData()
1515
{
1616
Data.SDKVersion = SDK_VERSION;
17-
Data.PartnerName = CoreSettings.PartnerSubdomainSettings.Subdomain;
17+
Data.PartnerName = CoreSettingsHandler.CoreSettings.Subdomain;
1818
Data.UnityVersion = Application.unityVersion;
1919
Data.UnityPlatform = Application.platform.ToString();
2020
Data.RenderPipeline = GetRenderPipeline();

Runtime/CoreSettings.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)