Skip to content

Commit 19834cb

Browse files
authored
Release 0.6.0 (#10)
Develop @ceeaaf81367202f49a106657c1e6daf488cd8adc
1 parent 2fd83d8 commit 19834cb

File tree

20 files changed

+252
-415
lines changed

20 files changed

+252
-415
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ucrp-20240629
1+
ucrp-20240725
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.5.0")]
4+
[assembly: ApiSourceVersion("Unity Cloud Reference Project", "0.6.0")]

ReferenceProject/Assets/_Application/NavigationModes/FlyMode/Scripts/FlyOrbitController.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading.Tasks;
44
using Unity.ReferenceProject.AppCamera;
55
using Unity.ReferenceProject.Common;
6+
using Unity.ReferenceProject.DataStreaming;
67
using Unity.ReferenceProject.Navigation;
78
using Unity.ReferenceProject.ObjectSelection;
89
using Unity.ReferenceProject.InputSystem;
@@ -59,15 +60,17 @@ public class FlyOrbitController : NavigationMode
5960
static readonly string k_PanGestureAction = "Pan Gesture Action";
6061
static readonly string k_ZoomGestureAction = "Zoom Gesture Action";
6162
static readonly string k_OrbitGestureAction = "Orbit Gesture Action";
62-
63+
64+
IDataStreamBound m_DataStreamBound;
6365
IObjectPicker m_ObjectPicker;
6466
ICameraProvider m_CameraProvider;
6567
IInputManager m_InputManager;
6668
InputScheme m_InputScheme;
6769

6870
[Inject]
69-
void Setup(IObjectPicker objectPicker, ICameraProvider cameraProvider, IInputManager inputManager)
71+
void Setup(IDataStreamBound dataStreamBound, IObjectPicker objectPicker, ICameraProvider cameraProvider, IInputManager inputManager)
7072
{
73+
m_DataStreamBound = dataStreamBound;
7174
m_ObjectPicker = objectPicker;
7275
m_CameraProvider = cameraProvider;
7376
m_InputManager = inputManager;
@@ -208,7 +211,8 @@ public void DisableInputs()
208211
public override void Teleport(Vector3 position, Vector3 eulerAngles)
209212
{
210213
var rotation = Quaternion.Euler(eulerAngles);
211-
var lookAt = rotation * new Vector3(0.0f, 0.0f, (Vector3.zero - position).magnitude) + position;
214+
var modelCenter = m_DataStreamBound.GetBound().center;
215+
var lookAt = rotation * new Vector3(0.0f, 0.0f, (modelCenter - position).magnitude) + position;
212216
m_CameraController.ResetTo(position, eulerAngles, lookAt);
213217
}
214218

ReferenceProject/Assets/_Application/Scripts/AppStates/AssetListState.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Unity.Cloud.AppLinking;
14
using Unity.Cloud.Assets;
25
using Unity.ReferenceProject.AssetManager;
36
using Unity.ReferenceProject.AssetList;
47
using Unity.ReferenceProject.DataStores;
8+
using Unity.ReferenceProject.DeepLinking;
59
using Unity.ReferenceProject.StateMachine;
610
using UnityEngine;
711
using Zenject;
@@ -14,34 +18,61 @@ public sealed class AssetListState : AppState
1418
AppState m_SceneSelectedState;
1519

1620
IAssetListController m_AssetListController;
21+
IDeepLinkingController m_DeepLinkingController;
22+
IUrlRedirectionInterceptor m_UrlRedirectionInterceptor;
1723

24+
Uri m_ForwardedDeepLink;
1825
PropertyValue<IAsset> m_IAsset;
1926

2027
[Inject]
21-
void Setup(IAssetListController assetListController, AssetManagerStore assetManagerStore)
28+
void Setup(IAssetListController assetListController, IDeepLinkingController deepLinkingController, IUrlRedirectionInterceptor urlRedirectionInterceptor, AssetManagerStore assetManagerStore)
2229
{
2330
m_AssetListController = assetListController;
31+
m_DeepLinkingController = deepLinkingController;
32+
m_UrlRedirectionInterceptor = urlRedirectionInterceptor;
33+
2434
m_IAsset = assetManagerStore.GetProperty<IAsset>(nameof(AssetManagerViewModel.Asset));
2535
}
2636

2737
void Awake()
2838
{
2939
m_AssetListController.AssetSelected += OnAssetSelected;
40+
m_UrlRedirectionInterceptor.DeepLinkForwarded += OnDeepLinkForwarded;
3041
}
3142

3243
void OnDestroy()
3344
{
3445
m_AssetListController.AssetSelected -= OnAssetSelected;
46+
m_UrlRedirectionInterceptor.DeepLinkForwarded -= OnDeepLinkForwarded;
3547
}
3648

3749
protected override async void EnterStateInternal()
3850
{
39-
await m_AssetListController.Refresh();
51+
if (!await TryConsumeForwardedDeepLink())
52+
{
53+
await m_AssetListController.Refresh();
54+
}
55+
}
56+
57+
async Task<bool> TryConsumeForwardedDeepLink()
58+
{
59+
if (m_ForwardedDeepLink == null)
60+
return false;
61+
62+
var deepLinkConsumptionSucceeded = await m_DeepLinkingController.TryConsumeUri(m_ForwardedDeepLink.AbsoluteUri);
63+
m_ForwardedDeepLink = null;
64+
65+
return deepLinkConsumptionSucceeded;
4066
}
4167

4268
void OnAssetSelected(IAsset asset)
4369
{
4470
AppStateController.PrepareTransition(m_SceneSelectedState).OnBeforeEnter(() => m_IAsset.SetValue(asset)).Apply();
4571
}
72+
73+
void OnDeepLinkForwarded(Uri uri)
74+
{
75+
m_ForwardedDeepLink = uri;
76+
}
4677
}
4778
}

ReferenceProject/Assets/_Modules/AppCamera/Runtime/Scripts/CameraProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public void Pan(Vector3 offset)
193193
public void PanStart(Vector2 pos)
194194
{
195195
var frustumCorners = new Vector3[4];
196-
var depth = -m_DesiredPosition.magnitude;
196+
var depth = -Vector3.Distance(m_DesiredLookAt, m_DesiredPosition);
197197
m_CameraProvider.Camera.CalculateFrustumCorners(new Rect(0, 0, 1, 1), depth, Camera.MonoOrStereoscopicEye.Mono, frustumCorners);
198198
m_PanningScale = Mathf.Abs((frustumCorners[2].x - frustumCorners[1].x) / Screen.width);
199199
}

ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetInfoUIController.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Unity.ReferenceProject.DataStreaming;
88
using UnityEngine;
99
using UnityEngine.UIElements;
10-
using Zenject;
1110
using Button = Unity.AppUI.UI.Button;
1211

1312
namespace Unity.ReferenceProject.AssetList
@@ -55,14 +54,6 @@ public class AssetInfoUIController : MonoBehaviour
5554
public event Action GenerateStreamableButtonClicked;
5655
public event Action<ProjectDescriptor> NeedProjectInfo;
5756

58-
IAssetRepository m_AssetRepository;
59-
60-
[Inject]
61-
void Setup(IAssetRepository assetRepository)
62-
{
63-
m_AssetRepository = assetRepository;
64-
}
65-
6657
void OnDestroy()
6758
{
6859
if (m_AssetPanel != null)
@@ -238,7 +229,8 @@ void UpdateAssetDisplayedInformation(IAsset asset)
238229
enumerable);
239230
break;
240231
case AssetType assetType:
241-
infoContainer = new AssetInformationContainerUI(k_LocalizedAssetList, assetType);
232+
infoContainer = new AssetInformationContainerUI(k_LocalizedAssetList + propertyName,
233+
assetType.GetValueAsString());
242234
break;
243235
case string stringValue:
244236
if (property.Name == "Status")

ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListController.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ public class AssetListController : IAssetListController
8585
readonly IAssetRepository m_AssetRepository;
8686
readonly IOrganizationRepository m_OrganizationRepository;
8787
readonly IPermissionsController m_PermissionsController;
88-
readonly IServiceHttpClient m_ServiceHttpClient;
8988

90-
public AssetListController(IAssetRepository assetRepository, IOrganizationRepository organizationRepository, IPermissionsController permissionsController, IServiceHttpClient serviceHttpClient)
89+
public AssetListController(IAssetRepository assetRepository, IOrganizationRepository organizationRepository, IPermissionsController permissionsController)
9190
{
9291
m_AssetRepository = assetRepository;
9392
m_OrganizationRepository = organizationRepository;
9493
m_PermissionsController = permissionsController;
95-
m_ServiceHttpClient = serviceHttpClient;
9694

9795
m_Filters = new AssetSearchFilter();
9896

@@ -213,15 +211,10 @@ public async Task<IEnumerable<IAssetProject>> GetAllProjects()
213211
{
214212
CancelToken();
215213

216-
// Get Projects info
217-
var url = $"https://services.unity.com/api/unity/legacy/v1/organizations/{SelectedOrganization.Id}/projects?limit=100";
218-
219-
var response = await m_ServiceHttpClient.GetAsync(url);
220-
var allProjectResponse = await response.JsonDeserializeAsync<AllProjectResponse>();
221-
222-
foreach (var project in allProjectResponse.results)
214+
var projectList = SelectedOrganization.ListProjectsAsync(Range.All);
215+
await foreach (var project in projectList)
223216
{
224-
TextureController.SetProjectIconUrl(project.id, project.iconUrl);
217+
TextureController.SetProjectIconUrl(project.Descriptor.ProjectId.ToString(), project.IconUrl);
225218
}
226219

227220
var projects = await GetAllProjectsInternal();

ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListUIController.cs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@
1616

1717
namespace Unity.ReferenceProject.AssetList
1818
{
19-
[Serializable]
20-
class AllProjectResponse
21-
{
22-
public List<AllProjectResponseItem> results { get; set; } = new();
23-
}
24-
25-
[Serializable]
26-
class AllProjectResponseItem
27-
{
28-
public string id { get; set; } = string.Empty;
29-
public string iconUrl { get; set; } = string.Empty;
30-
}
31-
3219
public class AssetCollectionInfo
3320
{
3421
public IAssetCollection Collection { get; set; }
@@ -398,24 +385,19 @@ async Task RefreshAsset()
398385
if (!m_AssetListController.IsCollectionSelected && m_AssetListController.SelectedProject != null)
399386
{
400387
m_RefreshCancellationTokenSource = new CancellationTokenSource();
401-
var collections = new List<IAssetCollection>();
388+
389+
var collectionInfos = new List<AssetCollectionInfo>();
390+
var filter = new AssetSearchFilter();
402391

403392
await foreach (var collection in m_AssetListController.SelectedProject.ListCollectionsAsync(Range.All, m_RefreshCancellationTokenSource.Token))
404393
{
405-
collections.Add(collection);
394+
filter.Collections.WhereContains(collection.Descriptor.Path);
395+
var assetCount = await m_AssetListController.SelectedProject.CountAssetsAsync(filter, m_RefreshCancellationTokenSource.Token);
396+
collectionInfos.Add(new AssetCollectionInfo { Collection = collection, AssetCount = assetCount });
406397
}
407398

408-
if (collections.Any())
399+
if (collectionInfos.Any())
409400
{
410-
var collectionInfos = new List<AssetCollectionInfo>();
411-
var filter = new AssetSearchFilter();
412-
foreach (var collection in collections)
413-
{
414-
filter.Collections.WhereContains(collection.Descriptor.Path);
415-
var assetCount = await m_AssetListController.SelectedProject.CountAssetsAsync(filter, m_RefreshCancellationTokenSource.Token);
416-
collectionInfos.Add(new AssetCollectionInfo { Collection = collection, AssetCount = assetCount });
417-
}
418-
419401
m_CollectionGrid.Populate(collectionInfos);
420402
}
421403
}

ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/ProjectUIController.cs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,34 +106,33 @@ public async Task PopulateCollections(IEnumerable<IAssetProject> projects)
106106
var collectionsContainer = projectItem.Q("CollectionsContainer");
107107
var collectionsList = collectionsContainer.Q("CollectionsList");
108108

109-
var collections = new List<IAssetCollection>();
110-
await foreach (var collection in project.ListCollectionsAsync(Range.All, CancellationToken.None))
111-
{
112-
collections.Add(collection);
113-
}
109+
var isInitialized = false;
114110

115-
if (collections.Any())
111+
await foreach (var collection in project.ListCollectionsAsync(Range.All, CancellationToken.None))
116112
{
117-
var caret = new Button();
118-
caret.quiet = true;
119-
caret.leadingIcon = k_CaretClose;
120-
caret.AddToClassList("button__project-list-item-caret");
121-
projectButton.hierarchy.Add(caret);
122-
caret.clicked += () => OnCaretClicked(caret, collectionsContainer);
123-
projectButton.clicked += () => OnCaretClicked(caret, collectionsContainer);
124-
125-
foreach (var collection in collections)
113+
if (!isInitialized)
126114
{
127-
var collectionButton = new ActionButton();
128-
collectionButton.quiet = true;
129-
collectionButton.AddToClassList("button__project-list-item-collection");
130-
collectionButton.label = collection.Name;
131-
collectionButton.tooltip = collection.Name;
132-
133-
collectionButton.clicked += () => CollectionSelected?.Invoke(collection);
134-
collectionsList.Add(collectionButton);
135-
m_Collections.TryAdd(collection.Descriptor.Path, collectionButton);
115+
isInitialized = true;
116+
var caret = new Button
117+
{
118+
quiet = true,
119+
leadingIcon = k_CaretClose
120+
};
121+
caret.AddToClassList("button__project-list-item-caret");
122+
projectButton.hierarchy.Add(caret);
123+
caret.clicked += () => OnCaretClicked(caret, collectionsContainer);
124+
projectButton.clicked += () => OnCaretClicked(caret, collectionsContainer);
136125
}
126+
127+
var collectionButton = new ActionButton();
128+
collectionButton.quiet = true;
129+
collectionButton.AddToClassList("button__project-list-item-collection");
130+
collectionButton.label = collection.Name;
131+
collectionButton.tooltip = collection.Name;
132+
133+
collectionButton.clicked += () => CollectionSelected?.Invoke(collection);
134+
collectionsList.Add(collectionButton);
135+
m_Collections.TryAdd(collection.Descriptor.Path, collectionButton);
137136
}
138137
}
139138
}

0 commit comments

Comments
 (0)