Skip to content

Commit 9f2a8d3

Browse files
committed
Release 0.1.2
develop @0333c838ac517ca5da0523f2b841a763837d25a2
1 parent 14f4e26 commit 9f2a8d3

File tree

425 files changed

+14936
-5665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

425 files changed

+14936
-5665
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ The Unity Reference Project is a fully functional collaborative design review to
1414

1515
To connect and find support, join the [Unity forum](https://forum.unity.com/forums/unity-cloud.868/).
1616

17-
### Supported platforms and files
17+
### Supported platforms
1818

19-
The Unity Reference Project is compatible with the [latest Unity Long Term Support](https://unity.com/releases/2021-lts) (LTS) and tested on the following platforms:
19+
The Unity Reference Project is currently compatible with [Unity Editor 2021.3.15f1](https://unity.com/releases/editor/qa/lts-releases?version=2021.3) (LTS) and will occassionally be updated to support newer versions. Builds are tested on the following platforms:
2020

2121
- Windows
22-
- MacOS
22+
- MacOS (Intel and Apple Silicon)
2323
- iOS
2424
- Android
2525
- WebGL
@@ -30,9 +30,10 @@ The Unity Reference Project is compatible with the [latest Unity Long Term Suppo
3030
- [Unity Reference Project](#unity-reference-project)
3131
- [A Unity project for building a collaborative 3D design review tool](#a-unity-project-for-building-a-collaborative-3d-design-review-tool)
3232
- [Get support](#get-support)
33-
- [Supported platforms and files](#supported-platforms-and-files)
33+
- [Supported platforms and files](#supported-platforms)
3434
- [Contents](#contents)
3535
- [Overview](#overview)
36+
- [Prerequisites](#prerequisites)
3637
- [Get the project](#get-the-project)
3738
- [Configure Unity services](#configure-unity-services)
3839
- [Sign into your Unity account](#sign-into-your-unity-account)
@@ -67,9 +68,18 @@ It also leverages Unity services that make it easier to:
6768
- Authenticate with your Unity account.
6869
- List and select an asset from cloud storage.
6970
- Stream a large 3D asset from cloud storage (vast support for 3D formats).
70-
- Collaborate online with voice chat and user avatars.
71+
- Online multiplayer collaboration.
7172
- Share a deep-link to an asset for others to view.
7273

74+
## Prerequisites
75+
76+
### MacOS
77+
78+
To open this Unity project on MacOS, you must have the Xcode commnand line tools installed.
79+
80+
1. Open the `Terminal` app on MacOS
81+
2. Enter the following command `xcode-select --install`
82+
7383
## Get the project
7484

7585
* To get the Reference project, you can clone or download it.
@@ -80,6 +90,8 @@ Configuring Unity services typically involves signing into your Unity account an
8090

8191
### Sign into your Unity account
8292

93+
> **Important**: The packages used in this project currently point to services hosted on GCP. When you sign in, ensure the toggle next to the `Sign In` button says `Using GCP`. This will change in an upcoming release that uses newer packages pointing to Azure.
94+
8395
* To sign in, go to the [Asset Manager](https://dashboard.unity3d.com/digital-twins/).
8496

8597
### Create an ID for your application

ReferenceProject/Assets/AddressableAssetsData/AssetGroups/Localization-Assets-Shared.asset

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReferenceProject/Assets/AddressableAssetsData/AssetGroups/Localization-String-Tables-English (en).asset

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReferenceProject/Assets/AddressableAssetsData/AssetGroups/Localization-String-Tables-French (fr).asset

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReferenceProject/Assets/Settings/URP/URP-Balanced-Renderer.asset

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReferenceProject/Assets/Settings/URP/URP-HighFidelity-Renderer.asset

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReferenceProject/Assets/Settings/URP/URP-Performant-Renderer.asset

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReferenceProject/Assets/Tests/Editor/EmptyConsoleTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class EmptyConsoleTests
2020
"With test categories:",
2121
"With test settings file:",
2222
"Executing tests with settings:",
23-
"Packages/com.unity.dt.app-ui/PackageResources/Styles/Components/ColorWheel.uss"
23+
"[Code Coverage]"
2424
};
2525
LogEntriesWrapper m_LogEntriesWrapper;
2626

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
using System;
22
using Unity.Cloud.Common;
33

4-
[assembly: ApiSourceVersion("Unity Cloud Reference Project", "0.1.1")]
4+
[assembly: ApiSourceVersion("Unity Cloud Reference Project", "0.1.2")]
Lines changed: 63 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System;
2+
using System.Linq;
23
using System.Threading.Tasks;
34
using Unity.Cloud.Common;
45
using Unity.Cloud.DataStreaming.Runtime;
6+
using Unity.Cloud.DeepLinking;
57
using Unity.ReferenceProject.DataStreaming;
8+
using Unity.ReferenceProject.DeepLinking;
69
using Unity.ReferenceProject.Navigation;
710
using UnityEngine;
811
using Zenject;
@@ -16,23 +19,23 @@ class CameraDefaultPositionController : MonoBehaviour
1619

1720
[SerializeField]
1821
float m_BoundsFillRatio = 0.9f;
19-
20-
[SerializeField]
21-
int m_VolumeProcessingIterations = 5;
22-
23-
[SerializeField]
24-
int m_VolumeProcessingDelay = 50;
2522

2623
IDataStreamer m_DataStreamer;
2724
INavigationManager m_NavigationManager;
2825
Camera m_StreamingCamera;
2926

3027
ISceneEvents m_SceneEvents;
28+
IDataStreamBound m_DataStreamBound;
3129

3230
bool m_IsProcessing;
3331

32+
IQueryArgumentsProcessor m_QueryArgumentsProcessor;
33+
QueryArgumentHandler<string> m_QueryArgumentCameraTransformHandler;
34+
DeepLinkCameraInfo m_SetDeepLinkCamera;
35+
3436
[Inject]
35-
void Setup(ISceneEvents sceneEvents, IDataStreamerProvider dataStreamerProvider, Camera streamingCamera, INavigationManager navigationManager)
37+
void Setup(ISceneEvents sceneEvents, IDataStreamerProvider dataStreamerProvider, Camera streamingCamera, INavigationManager navigationManager, IDataStreamBound dataStreamBound,
38+
IQueryArgumentsProcessor queryArgumentsProcessor, DeepLinkCameraInfo deepLinkCameraInfo)
3639
{
3740
m_SceneEvents = sceneEvents;
3841
m_SceneEvents.SceneOpened += OnSceneOpened;
@@ -42,12 +45,48 @@ void Setup(ISceneEvents sceneEvents, IDataStreamerProvider dataStreamerProvider,
4245

4346
m_StreamingCamera = streamingCamera;
4447
m_NavigationManager = navigationManager;
48+
m_DataStreamBound = dataStreamBound;
49+
50+
m_QueryArgumentsProcessor = queryArgumentsProcessor;
51+
m_SetDeepLinkCamera = deepLinkCameraInfo;
52+
}
53+
54+
void Awake()
55+
{
56+
m_QueryArgumentCameraTransformHandler = new QueryArgumentHandler<string>(
57+
"Camera Position",
58+
GetCameraPosition,
59+
SetCameraPosition
60+
);
61+
62+
m_QueryArgumentsProcessor.Register(m_QueryArgumentCameraTransformHandler, DeepLinkResourceType.Scene);
4563
}
4664

4765
void OnDestroy()
4866
{
4967
m_SceneEvents.SceneOpened -= OnSceneOpened;
5068
m_SceneEvents.SceneClosed -= OnSceneClosed;
69+
m_QueryArgumentsProcessor.Unregister(m_QueryArgumentCameraTransformHandler, DeepLinkResourceType.Scene);
70+
}
71+
72+
static string Vector3UrlFormat(Vector3 v)
73+
{
74+
return $"{v.x},{v.y},{v.z}";
75+
}
76+
public string GetCameraPosition()
77+
{
78+
return $"{Vector3UrlFormat(m_StreamingCamera.transform.position)}, {Vector3UrlFormat(m_StreamingCamera.transform.rotation.eulerAngles)}";
79+
}
80+
81+
void SetCameraPosition(string cameraString)
82+
{
83+
var splitValue = cameraString.Split(',').Select(i => float.TryParse(i, out float result) ? result : 0.0f).ToList();
84+
if (splitValue.Count > 5)
85+
{
86+
var newPosition = new Vector3(splitValue[0], splitValue[1], splitValue[2]);
87+
var newEulerAngle = new Vector3(splitValue[3], splitValue[4], splitValue[5]);
88+
m_NavigationManager.TryTeleport(newPosition, newEulerAngle);
89+
}
5190
}
5291

5392
void OnSceneOpened(IScene scene)
@@ -64,9 +103,17 @@ async void OnStreamingStateChanged(StreamingState state)
64103
{
65104
if (m_IsProcessing)
66105
return;
67-
106+
68107
m_IsProcessing = true;
69108

109+
if (m_SetDeepLinkCamera.SetDeepLinkCamera)
110+
{
111+
m_SetDeepLinkCamera.SetCameraReady?.Invoke(); // Process Deeplink QueryArguments
112+
m_DataStreamer.StreamingStateChanged -= OnStreamingStateChanged;
113+
m_IsProcessing = false;
114+
return;
115+
}
116+
70117
if (await ProcessDefaultVolumeOfInterestAsync())
71118
{
72119
m_DataStreamer.StreamingStateChanged -= OnStreamingStateChanged;
@@ -77,77 +124,21 @@ async void OnStreamingStateChanged(StreamingState state)
77124

78125
async Task<bool> ProcessDefaultVolumeOfInterestAsync()
79126
{
80-
var result = false;
81-
VolumeOfInterest prevVolume = new();
127+
var v = await m_DataStreamer.GetDefaultVolumeOfInterestAsync();
128+
129+
if (m_StreamingCamera == null) // Camera might have been destroyed since last loop.
130+
return false;
82131

83-
for (var i = 0; i < m_VolumeProcessingIterations; ++i)
84-
{
85-
var v = await m_DataStreamer.GetDefaultVolumeOfInterestAsync();
86-
if (v != prevVolume)
87-
{
88-
prevVolume = v;
89-
90-
if (m_StreamingCamera == null) // Camera might have been destroyed since last loop.
91-
return false;
92-
93-
SetView(v.Bounds, m_StreamingCamera);
94-
95-
await Task.Delay(m_VolumeProcessingDelay);
96-
}
97-
else
98-
{
99-
result = true;
100-
}
101-
}
132+
SetView(v.Bounds, m_StreamingCamera);
102133

103-
return result;
134+
return true;
104135
}
105136

106137
void SetView(Bounds bounds, Camera cam)
107138
{
108-
var (position, rotation) = CameraUtilities.CalculateViewFitPosition(bounds, m_PitchAngle, m_BoundsFillRatio,
109-
cam.fieldOfView, cam.aspect);
110-
139+
var (position, rotation) = m_DataStreamBound.CalculateViewFitPosition(bounds, m_PitchAngle,
140+
m_BoundsFillRatio, cam);
111141
m_NavigationManager.TryTeleport(position, rotation);
112142
}
113143
}
114-
115-
public static class CameraUtilities
116-
{
117-
public static (Vector3 position, Vector3 eulerAngles) CalculateViewFitPosition(Bounds bounds, float pitch, float fillRatio, float fieldOfView, float aspectRatio)
118-
{
119-
var desiredEuler = new Vector3(pitch, 0, 0);
120-
var distanceFromCenter = GetDistanceFromCenterToFit(bounds, fillRatio, fieldOfView, aspectRatio);
121-
var position = bounds.center - distanceFromCenter * (Quaternion.Euler(desiredEuler) * Vector3.forward);
122-
123-
return (position, desiredEuler);
124-
}
125-
126-
static float GetDistanceFromCenterToFit(Bounds bb, float fillRatio, float fovY, float aspectRatio)
127-
{
128-
var fovX = GetHorizontalFov(fovY, aspectRatio);
129-
var distanceToFitXAxisInView = GetDistanceFromCenter(bb, bb.extents.x, fovX, fillRatio);
130-
var distanceToFitYAxisInView = GetDistanceFromCenter(bb, bb.extents.y, fovY, fillRatio);
131-
132-
return Mathf.Max(distanceToFitXAxisInView, distanceToFitYAxisInView);
133-
}
134-
135-
static float GetHorizontalFov(float fovY, float aspectRatio)
136-
{
137-
var ratio = Mathf.Tan(Mathf.Deg2Rad * (fovY / 2.0f));
138-
return Mathf.Rad2Deg * Mathf.Atan(ratio * aspectRatio) * 2.0f;
139-
}
140-
141-
static float GetDistanceFromCenter(Bounds bb, float opposite, float fov, float fillRatio)
142-
{
143-
var lookAt = bb.center;
144-
145-
var angle = fov / 2.0f;
146-
var ratio = Mathf.Tan(Mathf.Deg2Rad * angle);
147-
var adjacent = opposite / ratio;
148-
var distanceFromLookAt = lookAt.z - bb.min.z + adjacent / fillRatio;
149-
150-
return distanceFromLookAt;
151-
}
152-
}
153144
}

0 commit comments

Comments
 (0)