Skip to content

Commit

Permalink
release v2.7.0 (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaduke28 committed Dec 18, 2023
1 parent ebfcc8d commit 3433666
Show file tree
Hide file tree
Showing 16 changed files with 309 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Editor/Api/ExternalCall.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Editor/Api/ExternalCall/GetWebRPCURLResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using UnityEngine;

namespace ClusterVR.CreatorKit.Editor.Api.ExternalCall
{
[Serializable]
public sealed class GetWebRPCURLResponse
{
[SerializeField] string url;

public string Url => url;
}
}
3 changes: 3 additions & 0 deletions Editor/Api/ExternalCall/GetWebRPCURLResponse.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Editor/Api/ExternalCall/RegisterWebRPCURLPayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using UnityEngine;

namespace ClusterVR.CreatorKit.Editor.Api.ExternalCall
{
[Serializable]
public sealed class RegisterWebRPCURLPayload
{
[SerializeField] string url;

public RegisterWebRPCURLPayload(string url)
{
this.url = url;
}
}
}
3 changes: 3 additions & 0 deletions Editor/Api/ExternalCall/RegisterWebRPCURLPayload.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Editor/Api/ExternalCall/RegisterWebRPCURLResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using UnityEngine;

namespace ClusterVR.CreatorKit.Editor.Api.ExternalCall
{
[Serializable]
public class RegisterWebRPCURLResponse
{
[SerializeField] string url;
[SerializeField] string verifyToken;

public string Url => url;
public string VerifyToken => verifyToken;
}
}
3 changes: 3 additions & 0 deletions Editor/Api/ExternalCall/RegisterWebRPCURLResponse.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Editor/Api/RPC/APIServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using ClusterVR.CreatorKit.Editor.Api.AccessoryTemplate;
using ClusterVR.CreatorKit.Editor.Api.Analytics;
using ClusterVR.CreatorKit.Editor.Api.ExternalCall;
using ClusterVR.CreatorKit.Editor.Api.ItemTemplate;
using ClusterVR.CreatorKit.Editor.Api.Venue;

Expand Down Expand Up @@ -125,5 +126,24 @@ public static Task<Groups> GetGroups(string accessToken, CancellationToken cance
return ApiClient.Get<Empty, OwnItemTemplateListResponse>(Empty.Value, accessToken,
$"{Constants.ApiBaseUrl}/v1/item_templates/own_for_creator?count={count}&filter={filter}&page={page}", cancellationToken);
}

public static async Task<GetWebRPCURLResponse> GetWebRPCURLAsync(string accessToken, CancellationToken cancellationToken)
{
return await ApiClient.Get<Empty, GetWebRPCURLResponse>(Empty.Value, accessToken, $"{Constants.ApiBaseUrl}/v1/user/web_rpc_url", cancellationToken);
}

public static async Task<RegisterWebRPCURLResponse> RegisterWebRPCURLAsync(
RegisterWebRPCURLPayload payload,
string accessToken, CancellationToken cancellationToken)
{
return await ApiClient.Post<RegisterWebRPCURLPayload, RegisterWebRPCURLResponse>(payload,
accessToken, $"{Constants.ApiBaseUrl}/v1/user/web_rpc_url",
cancellationToken);
}

public static async Task DeleteUserWebRPCURLAsync(string accessToken, CancellationToken cancellationToken)
{
await ApiClient.Post<Empty, Empty>(Empty.Value, accessToken, $"{Constants.ApiBaseUrl}/v1/user/web_rpc_url/delete", cancellationToken);
}
}
}
2 changes: 1 addition & 1 deletion Editor/Preview/EditorUI/PackageListRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static async Task UpdatePackageList(CancellationToken cancellationToken)
{
while (request.Status == StatusCode.InProgress)
{
await Task.Delay(TimeSpan.FromMilliseconds(10));
await Task.Delay(TimeSpan.FromMilliseconds(10), cancellationToken);
}
}
catch (Exception)
Expand Down
19 changes: 19 additions & 0 deletions Editor/Window/Uxml/ExternalCallUrlView.uxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="/UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement name="base-container">
<ui:VisualElement name="url-view">
<ui:Label name="current-url-title-label" text="登録中のURL" style="-unity-font-style: bold;" />
<ui:Label name="current-url-label" />
<ui:VisualElement style="height: 20px;" />
<ui:Label name="update-url-title-label" text="URLの登録" style="-unity-font-style: bold;" />
<ui:TextField name="update-url-field" />
<ui:Button name="update-button" text="登録" />
<ui:Button name="delete-button" text="削除" />
</ui:VisualElement>
<ui:VisualElement style="height: 20px;" />
<ui:VisualElement name="token-view">
<ui:Label text="verify用トークン" style="-unity-font-style: bold;" />
<ui:TextField name="token-field" readonly="true" />
<ui:Label text="* このトークンは一度しか表示されません。紛失した場合は URL を登録し直して下さい。" style="white-space: normal;" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>
3 changes: 3 additions & 0 deletions Editor/Window/Uxml/ExternalCallUrlView.uxml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

154 changes: 154 additions & 0 deletions Editor/Window/View/ExternalCallUrlView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using ClusterVR.CreatorKit.Editor.Api.ExternalCall;
using ClusterVR.CreatorKit.Editor.Api.RPC;
using ClusterVR.CreatorKit.Editor.Api.User;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

namespace ClusterVR.CreatorKit.Editor.Window.View
{
public sealed class ExternalCallUrlView : IRequireTokenAuthMainView, IDisposable
{
const string MainTemplatePath = "Packages/mu.cluster.cluster-creator-kit/Editor/Window/Uxml/ExternalCallUrlView.uxml";

UserInfo userInfo;
Label currentUrlLabel;
TextField updateUrlTextField;
Button updateButton;
Button deleteButton;
VisualElement tokenView;
TextField tokenField;
readonly CancellationTokenSource cancellationTokenSource = new();

public VisualElement LoginAndCreateView(UserInfo userInfo)
{
this.userInfo = userInfo;

var mainView = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(MainTemplatePath).CloneTree();
currentUrlLabel = mainView.Q<Label>("current-url-label");
updateUrlTextField = mainView.Q<TextField>("update-url-field");

updateButton = mainView.Q<Button>("update-button");
deleteButton = mainView.Q<Button>("delete-button");

tokenView = mainView.Q<VisualElement>("token-view");
tokenField = mainView.Q<TextField>("token-field");

updateButton.clicked += OnUpdateClicked;
deleteButton.clicked += OnDeleteClicked;

_ = InitializeAsync(cancellationTokenSource.Token);
return mainView;
}

void OnUpdateClicked()
{
if (EditorUtility.DisplayDialog("確認", "URLを更新しますか?", "OK", "キャンセル"))
{
_ = UpdateWebRPCUrlAsync(cancellationTokenSource.Token);
}
}

void OnDeleteClicked()
{
if (EditorUtility.DisplayDialog("確認", "URLを削除しますか?", "OK", "キャンセル"))
{
_ = DeleteWebRPCUrlAsync(cancellationTokenSource.Token);
}
}

async Task InitializeAsync(CancellationToken cancellationToken)
{
tokenView.visible = false;
var currentUrl = await GetWebRPCUrlAsync(cancellationToken);
SetCurrentURL(currentUrl);
}

void SetCurrentURL(string url)
{
if (string.IsNullOrEmpty(url))
{
currentUrlLabel.text = "未登録";
deleteButton.SetEnabled(false);
}
else
{
currentUrlLabel.text = url;
deleteButton.SetEnabled(true);
}
}

async Task<string> GetWebRPCUrlAsync(CancellationToken cancellationToken)
{
try
{
var res = await APIServiceClient.GetWebRPCURLAsync(userInfo.VerifiedToken, cancellationToken);
return res.Url;
}
catch (Failure e) when (e.StatusCode == 404)
{
return null;
}
catch (Exception e) when (e is not OperationCanceledException)
{
Debug.LogException(e);
throw;
}
}

async Task UpdateWebRPCUrlAsync(CancellationToken cancellationToken)
{
var url = updateUrlTextField.value;
if (string.IsNullOrEmpty(url)) return;

try
{
var res = await APIServiceClient.RegisterWebRPCURLAsync(new RegisterWebRPCURLPayload(url), userInfo.VerifiedToken, cancellationToken);
SetCurrentURL(res.Url);
tokenView.visible = true;
tokenField.value = res.VerifyToken;
}
catch (Failure e) when (e.StatusCode == 400)
{
EditorUtility.DisplayDialog("エラー", e.Error.Detail, "OK");
throw;
}
catch (Exception e) when (e is not OperationCanceledException)
{
Debug.LogException(e);
throw;
}
}

async Task DeleteWebRPCUrlAsync(CancellationToken cancellationToken)
{
try
{
await APIServiceClient.DeleteUserWebRPCURLAsync(userInfo.VerifiedToken, cancellationToken);
SetCurrentURL(null);
tokenView.visible = false;
tokenField.value = null;
}
catch (Exception e) when (e is not OperationCanceledException)
{
Debug.LogException(e);
throw;
}
}

public void Logout()
{
SetCurrentURL(null);
tokenField.visible = false;
}

public void Dispose()
{
cancellationTokenSource.Cancel();
cancellationTokenSource.Dispose();
}
}
}
3 changes: 3 additions & 0 deletions Editor/Window/View/ExternalCallUrlView.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions Editor/Window/View/ExternalCallUrlWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

namespace ClusterVR.CreatorKit.Editor.Window.View
{
public sealed class ExternalCallUrlWindow : EditorWindow
{
readonly ExternalCallUrlView externalCallUrlView = new();
RequireTokenAuthView tokenAuthView;

[MenuItem("Cluster/外部通信(callExternal)接続先URL", priority = 305)]
public static void Open()
{
var window = GetWindow<ExternalCallUrlWindow>();
window.titleContent = new GUIContent("外部通信(callExternal)接続先URL");
}

void OnEnable()
{
var view = CreateView();
rootVisualElement.Add(view);
}

void OnDisable()
{
rootVisualElement.Clear();
if (tokenAuthView != null)
{
tokenAuthView.Dispose();
tokenAuthView = null;
}
}

void OnDestroy()
{
externalCallUrlView.Dispose();
}

VisualElement CreateView()
{
tokenAuthView = new RequireTokenAuthView(externalCallUrlView);
var authView = tokenAuthView.CreateView();
authView.SetEnabled(true);

return authView;
}
}
}
3 changes: 3 additions & 0 deletions Editor/Window/View/ExternalCallUrlWindow.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Cluster, Inc.",
"name": "mu.cluster.cluster-creator-kit",
"version": "2.6.0",
"version": "2.7.0",
"displayName": "Cluster Creator Kit",
"unity": "2021.3",
"description": "Cluster Creator Kit \u3067\u30d0\u30fc\u30c1\u30e3\u30eb\u7a7a\u9593\u3092\u69cb\u7bc9\u3059\u308b\u3068\u3001 cluster \u3092\u901a\u3057\u3066\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u3084PC/VR\u30d8\u30c3\u30c9\u30de\u30a6\u30f3\u30c8\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306a\u3069\u69d8\u3005\u306a\u30c7\u30d0\u30a4\u30b9\u304b\u3089\u4f53\u9a13\u3067\u304d\u307e\u3059\u3002",
Expand Down

0 comments on commit 3433666

Please sign in to comment.