Skip to content

Commit

Permalink
Release v1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
noir-neo committed Apr 7, 2020
1 parent 51afcde commit 1a8ed10
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Editor/Core/Constants.cs
Expand Up @@ -27,7 +27,7 @@ public static class Constants
public static string LastBuildAndroidKey => "LastBuildAndroid";
public static string LastBuildIOSKey => "LastBuildIOS";
public static string LastExportPackageKey => "LastExportPackage";
public static string OpenWorldDetailPageAfterUploadKey => "OpenWorldDetailPageAfterUpload";
public static string OpenWorldManagementPageAfterUploadKey => "OpenWorldManagementPageAfterUpload";

// package の version (SemVer)
public static string GetCreatorKitVersion()
Expand Down
6 changes: 3 additions & 3 deletions Editor/Core/EditorPrefsUtils.cs
Expand Up @@ -39,10 +39,10 @@ public static string LastExportPackage
set => EditorPrefs.SetString(Constants.LastExportPackageKey, value);
}

public static bool OpenWorldDetailPageAfterUpload
public static bool OpenWorldManagementPageAfterUpload
{
get => EditorPrefs.GetBool(Constants.OpenWorldDetailPageAfterUploadKey, true);
set => EditorPrefs.SetBool(Constants.OpenWorldDetailPageAfterUploadKey, value);
get => EditorPrefs.GetBool(Constants.OpenWorldManagementPageAfterUploadKey, true);
set => EditorPrefs.SetBool(Constants.OpenWorldManagementPageAfterUploadKey, value);
}
}
}
10 changes: 10 additions & 0 deletions Editor/Core/Venue/Json/PostNotifyFinishedUploadPayload.cs
@@ -0,0 +1,10 @@
using System;

namespace ClusterVR.CreatorKit.Editor.Core.Venue.Json
{
[Serializable]
public class PostNotifyFinishedUploadPayload
{
public bool isPublish;
}
}

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

2 changes: 2 additions & 0 deletions Editor/Core/Venue/Json/StringValueObject.cs
Expand Up @@ -36,5 +36,7 @@ public StringValueObject(string value)
{
Value = value;
}

public override string ToString() => Value;
}
}
9 changes: 8 additions & 1 deletion Editor/Core/Venue/PostNotifyFinishedUploadService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Text;
using ClusterVR.CreatorKit.Editor.Core.Venue.Json;
using UnityEngine;
using UnityEngine.Networking;
Expand All @@ -11,6 +12,7 @@ public class PostNotifyFinishedUploadService
readonly string accessToken;
readonly VenueID venueId;
readonly UploadRequestID uploadRequestId;
readonly bool isPublish;
readonly Action<VenueUploadRequestCompletionResponse> onSuccess;
readonly Action<Exception> onError;

Expand All @@ -21,13 +23,15 @@ public class PostNotifyFinishedUploadService
string accessToken,
VenueID venueId,
UploadRequestID uploadRequestId,
bool isPublish,
Action<VenueUploadRequestCompletionResponse> onSuccess = null,
Action<Exception> onError = null
)
{
this.accessToken = accessToken;
this.venueId = venueId;
this.uploadRequestId = uploadRequestId;
this.isPublish = isPublish;
this.onSuccess = onSuccess;
this.onError = onError;
}
Expand All @@ -40,9 +44,12 @@ public void Run()
IEnumerator PostNotifyFinishedUpload()
{
isProcessing = true;
var notifyFinishedUrl = $"{Constants.VenueApiBaseUrl}/v1/venues/{venueId.Value}/upload/{uploadRequestId.Value}/done";
// 互換性のためRequestParameterとBody両方に入れる
var notifyFinishedUrl = $"{Constants.VenueApiBaseUrl}/v1/venues/{venueId.Value}/upload/{uploadRequestId.Value}/done?isPublish={isPublish}";
var notifyFinishedRequst = ClusterApiUtil.CreateUnityWebRequest(accessToken, notifyFinishedUrl,UnityWebRequest.kHttpVerbPOST);
notifyFinishedRequst.downloadHandler = new DownloadHandlerBuffer();
var payload = new PostNotifyFinishedUploadPayload {isPublish = isPublish};
notifyFinishedRequst.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(JsonUtility.ToJson(payload)));

notifyFinishedRequst.SendWebRequest();

Expand Down
1 change: 1 addition & 0 deletions Editor/Core/Venue/UploadVenueService.cs
Expand Up @@ -277,6 +277,7 @@ IEnumerator UploadVenue()
accessToken,
venue.VenueId,
uploadRequestId,
false,
request =>
{
Debug.Log($"notify finished upload request, Request ID : {request.UploadRequestId}");
Expand Down
11 changes: 11 additions & 0 deletions Editor/Preview/Bootstrap.cs
@@ -1,9 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ClusterVR.CreatorKit.Editor.Preview.EditorSettings;
using ClusterVR.CreatorKit.Editor.Preview.EditorUI;
using ClusterVR.CreatorKit.Editor.Preview.World;
using ClusterVR.CreatorKit.Editor.Venue;
using ClusterVR.CreatorKit.Item;
using ClusterVR.CreatorKit.Preview.Item;
using ClusterVR.CreatorKit.World;
using UnityEditor;
using UnityEngine;
Expand All @@ -29,9 +32,15 @@ static Bootstrap()
await OnChangePlayModeAsync(playMode);
OnChangePlayMode(playMode);
};
SetupProject();
#endif
}

static void SetupProject()
{
ProjectSettingsConfigurer.Setup();
}

static void OnChangePlayMode(PlayModeStateChange playMode)
{
switch (playMode)
Expand Down Expand Up @@ -60,6 +69,8 @@ static void OnChangePlayMode(PlayModeStateChange playMode)
PlayerPresenter = new PlayerPresenter(PermissionType.Audience, enterDeviceType);
new AvatarRespawner(despawnHeight, PlayerPresenter);

new ItemRespawner(despawnHeight, GetComponentsInGameObjectsChildren<IMovableItem>(rootGameObjects));

var mainScreenViews = GetComponentsInGameObjectsChildren<IMainScreenView>(rootGameObjects);
MainScreenPresenter = new MainScreenPresenter(mainScreenViews);

Expand Down
3 changes: 2 additions & 1 deletion Editor/Preview/ClusterVR.CreatorKit.Editor.Preview.asmdef
Expand Up @@ -5,7 +5,8 @@
"ClusterVR.CreatorKit.World",
"ClusterVR.CreatorKit.Preview",
"Unity.Postprocessing.Runtime",
"ClusterVR.CreatorKit.Constants"
"ClusterVR.CreatorKit.Constants",
"ClusterVR.CreatorKit.Item"
],
"includePlatforms": [
"Editor"
Expand Down
3 changes: 3 additions & 0 deletions Editor/Preview/EditorSettings.meta

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

12 changes: 12 additions & 0 deletions Editor/Preview/EditorSettings/ProjectSettingsConfigurer.cs
@@ -0,0 +1,12 @@
using UnityEngine;

namespace ClusterVR.CreatorKit.Editor.Preview.EditorSettings
{
public static class ProjectSettingsConfigurer
{
public static void Setup()
{
Physics.autoSyncTransforms = true;
}
}
}

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

18 changes: 9 additions & 9 deletions Editor/Venue/UploadVenueView.cs
Expand Up @@ -15,6 +15,7 @@ public class UploadVenueView
readonly UserInfo userInfo;
readonly Core.Venue.Json.Venue venue;
string worldDetailUrl;
readonly string worldManagementUrl;

bool executeUpload;
string errorMessage;
Expand All @@ -28,6 +29,7 @@ public UploadVenueView(UserInfo userInfo, Core.Venue.Json.Venue venue, ImageView
this.venue = venue;
this.thumbnail = thumbnail;
worldDetailUrl = venue.WorldDetailUrl;
worldManagementUrl = ClusterVR.CreatorKit.Editor.Core.Constants.WebBaseUrl + "/account/worlds";
}

public VisualElement CreateView()
Expand Down Expand Up @@ -69,9 +71,9 @@ void Process()
{
errorMessage = "";
worldDetailUrl = completionResponse.Url;
if (EditorPrefsUtils.OpenWorldDetailPageAfterUpload)
if (EditorPrefsUtils.OpenWorldManagementPageAfterUpload)
{
Application.OpenURL(completionResponse.Url);
Application.OpenURL(worldManagementUrl);
}
},
exception =>
Expand All @@ -88,7 +90,7 @@ void Process()
void DrawUI()
{
EditorGUILayout.Space();
EditorPrefsUtils.OpenWorldDetailPageAfterUpload = EditorGUILayout.ToggleLeft("アップロード後にワールドページを開く", EditorPrefsUtils.OpenWorldDetailPageAfterUpload);
EditorPrefsUtils.OpenWorldManagementPageAfterUpload = EditorGUILayout.ToggleLeft("アップロード後にワールド管理ページを開く", EditorPrefsUtils.OpenWorldManagementPageAfterUpload);
EditorGUILayout.HelpBox("アップロードするシーンを開いておいてください。", MessageType.Info);

if (thumbnail.IsEmpty)
Expand All @@ -103,18 +105,16 @@ void DrawUI()
{
executeUpload = EditorUtility.DisplayDialog(
"ワールドをアップロードする",
$"公開ワールド'{venue.Name}'としてアップロードします。よろしいですか?",
$"'{venue.Name}'としてアップロードします。よろしいですか?",
"アップロード",
"キャンセル"
);
}
}
using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(worldDetailUrl)))

if (GUILayout.Button("ワールド管理ページを開く"))
{
if (GUILayout.Button("ワールドページを開く"))
{
Application.OpenURL(worldDetailUrl);
}
Application.OpenURL(worldManagementUrl);
}

EditorGUILayout.Space();
Expand Down
1 change: 1 addition & 0 deletions Runtime/Item/IMovableItem.cs
Expand Up @@ -11,5 +11,6 @@ public interface IMovableItem
void SetPositionAndRotation(Vector3 position, Quaternion rotation);
// Physics を使う Item の場合は有効化する
void EnablePhysics();
void Respawn();
}
}
51 changes: 24 additions & 27 deletions Runtime/Item/Implements/MovableItem.cs
Expand Up @@ -19,6 +19,8 @@ enum State
}

bool isInitialized;
Vector3 initialPosition;
Quaternion initialRotation;
bool initialIsKinematic;

State state = State.Free;
Expand All @@ -32,13 +34,15 @@ enum State
void CacheInitialValue()
{
if (isInitialized) return;
initialPosition = transform.position;
initialRotation = transform.rotation;
initialIsKinematic = rb.isKinematic;
isInitialized = true;
}

void Start()
{
StartCoroutine(Rewind());
CacheInitialValue();
}

public void SetPositionAndRotation(Vector3 position, Quaternion rotation)
Expand All @@ -60,39 +64,24 @@ public void SetPositionAndRotation(Vector3 position, Quaternion rotation)
setAt = Time.realtimeSinceStartup;
interpolateDurationSeconds = Time.deltaTime;
state = State.Controlled;
}

void LateUpdate()
{
if (state == State.Controlled)
{
transform.position = targetPosition;
transform.rotation = targetRotation;
}
}

IEnumerator Rewind()
{
while (true)
{
yield return new WaitForEndOfFrame();
if (state == State.Controlled)
{
transform.position = currentPosition;
transform.rotation = currentRotation;
}
}
transform.position = targetPosition;
transform.rotation = targetRotation;
}

void FixedUpdate()
{
if (state != State.Free)
if (state == State.Free) return;

if (state == State.Controlled)
{
var interpolateRate = (Time.realtimeSinceStartup - setAt) / interpolateDurationSeconds;
rb.MovePosition(Vector3.Lerp(currentPosition, targetPosition, interpolateRate));
rb.MoveRotation(Quaternion.Slerp(currentRotation, targetRotation, interpolateRate));
rb.position = currentPosition;
rb.rotation = currentRotation;
state = State.Interpolated;
}

var interpolateRate = (Time.realtimeSinceStartup - setAt) / interpolateDurationSeconds;
rb.MovePosition(Vector3.Lerp(currentPosition, targetPosition, interpolateRate));
rb.MoveRotation(Quaternion.Slerp(currentRotation, targetRotation, interpolateRate));
}

public void EnablePhysics()
Expand All @@ -112,6 +101,14 @@ static Vector3 GetAngularVelocity(Quaternion from, Quaternion to, float deltaTim
else return deltaAngle * Mathf.Deg2Rad / deltaTime * (from * deltaAngleAxis);
}

public void Respawn()
{
transform.position = initialPosition;
transform.rotation = initialRotation;
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
}

void Reset()
{
item = GetComponent<Item>();
Expand Down
33 changes: 33 additions & 0 deletions Runtime/Preview/Item/ItemRespawner.cs
@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ClusterVR.CreatorKit.Item;
using UnityEngine;

namespace ClusterVR.CreatorKit.Preview.Item
{
public sealed class ItemRespawner
{
readonly float despawnHeight;
readonly List<IMovableItem> movableItems;

public ItemRespawner (float despawnHeight, IEnumerable<IMovableItem> movableItems)
{
this.despawnHeight = despawnHeight;
this.movableItems = movableItems.ToList();
CheckHeight();
}

async void CheckHeight()
{
while (Application.isPlaying)
{
foreach (var movableItem in movableItems)
{
if (movableItem.Position.y < despawnHeight) movableItem.Respawn();
}
await Task.Delay(300);
}
}
}
}
3 changes: 3 additions & 0 deletions Runtime/Preview/Item/ItemRespawner.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
@@ -1,6 +1,6 @@
{
"name": "mu.cluster.cluster-creator-kit",
"version": "1.2.1",
"version": "1.2.2",
"displayName": "Cluster Creator Kit",
"unity": "2019.2",
"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 1a8ed10

Please sign in to comment.