Skip to content

Commit

Permalink
Release 0.6.0 (#10)
Browse files Browse the repository at this point in the history
Develop @ceeaaf81367202f49a106657c1e6daf488cd8adc
  • Loading branch information
ChafikUnity authored Sep 4, 2024
1 parent 2fd83d8 commit 19834cb
Show file tree
Hide file tree
Showing 20 changed files with 252 additions and 415 deletions.
2 changes: 1 addition & 1 deletion ReferenceProject/Assets/Build/ucrp_base_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ucrp-20240629
ucrp-20240725
2 changes: 1 addition & 1 deletion ReferenceProject/Assets/_Application/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using Unity.Cloud.Common;

[assembly: ApiSourceVersion("Unity Cloud Reference Project", "0.5.0")]
[assembly: ApiSourceVersion("Unity Cloud Reference Project", "0.6.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Unity.ReferenceProject.AppCamera;
using Unity.ReferenceProject.Common;
using Unity.ReferenceProject.DataStreaming;
using Unity.ReferenceProject.Navigation;
using Unity.ReferenceProject.ObjectSelection;
using Unity.ReferenceProject.InputSystem;
Expand Down Expand Up @@ -59,15 +60,17 @@ public class FlyOrbitController : NavigationMode
static readonly string k_PanGestureAction = "Pan Gesture Action";
static readonly string k_ZoomGestureAction = "Zoom Gesture Action";
static readonly string k_OrbitGestureAction = "Orbit Gesture Action";


IDataStreamBound m_DataStreamBound;
IObjectPicker m_ObjectPicker;
ICameraProvider m_CameraProvider;
IInputManager m_InputManager;
InputScheme m_InputScheme;

[Inject]
void Setup(IObjectPicker objectPicker, ICameraProvider cameraProvider, IInputManager inputManager)
void Setup(IDataStreamBound dataStreamBound, IObjectPicker objectPicker, ICameraProvider cameraProvider, IInputManager inputManager)
{
m_DataStreamBound = dataStreamBound;
m_ObjectPicker = objectPicker;
m_CameraProvider = cameraProvider;
m_InputManager = inputManager;
Expand Down Expand Up @@ -208,7 +211,8 @@ public void DisableInputs()
public override void Teleport(Vector3 position, Vector3 eulerAngles)
{
var rotation = Quaternion.Euler(eulerAngles);
var lookAt = rotation * new Vector3(0.0f, 0.0f, (Vector3.zero - position).magnitude) + position;
var modelCenter = m_DataStreamBound.GetBound().center;
var lookAt = rotation * new Vector3(0.0f, 0.0f, (modelCenter - position).magnitude) + position;
m_CameraController.ResetTo(position, eulerAngles, lookAt);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
using System.Threading.Tasks;
using Unity.Cloud.AppLinking;
using Unity.Cloud.Assets;
using Unity.ReferenceProject.AssetManager;
using Unity.ReferenceProject.AssetList;
using Unity.ReferenceProject.DataStores;
using Unity.ReferenceProject.DeepLinking;
using Unity.ReferenceProject.StateMachine;
using UnityEngine;
using Zenject;
Expand All @@ -14,34 +18,61 @@ public sealed class AssetListState : AppState
AppState m_SceneSelectedState;

IAssetListController m_AssetListController;
IDeepLinkingController m_DeepLinkingController;
IUrlRedirectionInterceptor m_UrlRedirectionInterceptor;

Uri m_ForwardedDeepLink;
PropertyValue<IAsset> m_IAsset;

[Inject]
void Setup(IAssetListController assetListController, AssetManagerStore assetManagerStore)
void Setup(IAssetListController assetListController, IDeepLinkingController deepLinkingController, IUrlRedirectionInterceptor urlRedirectionInterceptor, AssetManagerStore assetManagerStore)
{
m_AssetListController = assetListController;
m_DeepLinkingController = deepLinkingController;
m_UrlRedirectionInterceptor = urlRedirectionInterceptor;

m_IAsset = assetManagerStore.GetProperty<IAsset>(nameof(AssetManagerViewModel.Asset));
}

void Awake()
{
m_AssetListController.AssetSelected += OnAssetSelected;
m_UrlRedirectionInterceptor.DeepLinkForwarded += OnDeepLinkForwarded;
}

void OnDestroy()
{
m_AssetListController.AssetSelected -= OnAssetSelected;
m_UrlRedirectionInterceptor.DeepLinkForwarded -= OnDeepLinkForwarded;
}

protected override async void EnterStateInternal()
{
await m_AssetListController.Refresh();
if (!await TryConsumeForwardedDeepLink())
{
await m_AssetListController.Refresh();
}
}

async Task<bool> TryConsumeForwardedDeepLink()
{
if (m_ForwardedDeepLink == null)
return false;

var deepLinkConsumptionSucceeded = await m_DeepLinkingController.TryConsumeUri(m_ForwardedDeepLink.AbsoluteUri);
m_ForwardedDeepLink = null;

return deepLinkConsumptionSucceeded;
}

void OnAssetSelected(IAsset asset)
{
AppStateController.PrepareTransition(m_SceneSelectedState).OnBeforeEnter(() => m_IAsset.SetValue(asset)).Apply();
}

void OnDeepLinkForwarded(Uri uri)
{
m_ForwardedDeepLink = uri;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void Pan(Vector3 offset)
public void PanStart(Vector2 pos)
{
var frustumCorners = new Vector3[4];
var depth = -m_DesiredPosition.magnitude;
var depth = -Vector3.Distance(m_DesiredLookAt, m_DesiredPosition);
m_CameraProvider.Camera.CalculateFrustumCorners(new Rect(0, 0, 1, 1), depth, Camera.MonoOrStereoscopicEye.Mono, frustumCorners);
m_PanningScale = Mathf.Abs((frustumCorners[2].x - frustumCorners[1].x) / Screen.width);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Unity.ReferenceProject.DataStreaming;
using UnityEngine;
using UnityEngine.UIElements;
using Zenject;
using Button = Unity.AppUI.UI.Button;

namespace Unity.ReferenceProject.AssetList
Expand Down Expand Up @@ -55,14 +54,6 @@ public class AssetInfoUIController : MonoBehaviour
public event Action GenerateStreamableButtonClicked;
public event Action<ProjectDescriptor> NeedProjectInfo;

IAssetRepository m_AssetRepository;

[Inject]
void Setup(IAssetRepository assetRepository)
{
m_AssetRepository = assetRepository;
}

void OnDestroy()
{
if (m_AssetPanel != null)
Expand Down Expand Up @@ -238,7 +229,8 @@ void UpdateAssetDisplayedInformation(IAsset asset)
enumerable);
break;
case AssetType assetType:
infoContainer = new AssetInformationContainerUI(k_LocalizedAssetList, assetType);
infoContainer = new AssetInformationContainerUI(k_LocalizedAssetList + propertyName,
assetType.GetValueAsString());
break;
case string stringValue:
if (property.Name == "Status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,12 @@ public class AssetListController : IAssetListController
readonly IAssetRepository m_AssetRepository;
readonly IOrganizationRepository m_OrganizationRepository;
readonly IPermissionsController m_PermissionsController;
readonly IServiceHttpClient m_ServiceHttpClient;

public AssetListController(IAssetRepository assetRepository, IOrganizationRepository organizationRepository, IPermissionsController permissionsController, IServiceHttpClient serviceHttpClient)
public AssetListController(IAssetRepository assetRepository, IOrganizationRepository organizationRepository, IPermissionsController permissionsController)
{
m_AssetRepository = assetRepository;
m_OrganizationRepository = organizationRepository;
m_PermissionsController = permissionsController;
m_ServiceHttpClient = serviceHttpClient;

m_Filters = new AssetSearchFilter();

Expand Down Expand Up @@ -213,15 +211,10 @@ public async Task<IEnumerable<IAssetProject>> GetAllProjects()
{
CancelToken();

// Get Projects info
var url = $"https://services.unity.com/api/unity/legacy/v1/organizations/{SelectedOrganization.Id}/projects?limit=100";

var response = await m_ServiceHttpClient.GetAsync(url);
var allProjectResponse = await response.JsonDeserializeAsync<AllProjectResponse>();

foreach (var project in allProjectResponse.results)
var projectList = SelectedOrganization.ListProjectsAsync(Range.All);
await foreach (var project in projectList)
{
TextureController.SetProjectIconUrl(project.id, project.iconUrl);
TextureController.SetProjectIconUrl(project.Descriptor.ProjectId.ToString(), project.IconUrl);
}

var projects = await GetAllProjectsInternal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@

namespace Unity.ReferenceProject.AssetList
{
[Serializable]
class AllProjectResponse
{
public List<AllProjectResponseItem> results { get; set; } = new();
}

[Serializable]
class AllProjectResponseItem
{
public string id { get; set; } = string.Empty;
public string iconUrl { get; set; } = string.Empty;
}

public class AssetCollectionInfo
{
public IAssetCollection Collection { get; set; }
Expand Down Expand Up @@ -398,24 +385,19 @@ async Task RefreshAsset()
if (!m_AssetListController.IsCollectionSelected && m_AssetListController.SelectedProject != null)
{
m_RefreshCancellationTokenSource = new CancellationTokenSource();
var collections = new List<IAssetCollection>();

var collectionInfos = new List<AssetCollectionInfo>();
var filter = new AssetSearchFilter();

await foreach (var collection in m_AssetListController.SelectedProject.ListCollectionsAsync(Range.All, m_RefreshCancellationTokenSource.Token))
{
collections.Add(collection);
filter.Collections.WhereContains(collection.Descriptor.Path);
var assetCount = await m_AssetListController.SelectedProject.CountAssetsAsync(filter, m_RefreshCancellationTokenSource.Token);
collectionInfos.Add(new AssetCollectionInfo { Collection = collection, AssetCount = assetCount });
}

if (collections.Any())
if (collectionInfos.Any())
{
var collectionInfos = new List<AssetCollectionInfo>();
var filter = new AssetSearchFilter();
foreach (var collection in collections)
{
filter.Collections.WhereContains(collection.Descriptor.Path);
var assetCount = await m_AssetListController.SelectedProject.CountAssetsAsync(filter, m_RefreshCancellationTokenSource.Token);
collectionInfos.Add(new AssetCollectionInfo { Collection = collection, AssetCount = assetCount });
}

m_CollectionGrid.Populate(collectionInfos);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,33 @@ public async Task PopulateCollections(IEnumerable<IAssetProject> projects)
var collectionsContainer = projectItem.Q("CollectionsContainer");
var collectionsList = collectionsContainer.Q("CollectionsList");

var collections = new List<IAssetCollection>();
await foreach (var collection in project.ListCollectionsAsync(Range.All, CancellationToken.None))
{
collections.Add(collection);
}
var isInitialized = false;

if (collections.Any())
await foreach (var collection in project.ListCollectionsAsync(Range.All, CancellationToken.None))
{
var caret = new Button();
caret.quiet = true;
caret.leadingIcon = k_CaretClose;
caret.AddToClassList("button__project-list-item-caret");
projectButton.hierarchy.Add(caret);
caret.clicked += () => OnCaretClicked(caret, collectionsContainer);
projectButton.clicked += () => OnCaretClicked(caret, collectionsContainer);

foreach (var collection in collections)
if (!isInitialized)
{
var collectionButton = new ActionButton();
collectionButton.quiet = true;
collectionButton.AddToClassList("button__project-list-item-collection");
collectionButton.label = collection.Name;
collectionButton.tooltip = collection.Name;

collectionButton.clicked += () => CollectionSelected?.Invoke(collection);
collectionsList.Add(collectionButton);
m_Collections.TryAdd(collection.Descriptor.Path, collectionButton);
isInitialized = true;
var caret = new Button
{
quiet = true,
leadingIcon = k_CaretClose
};
caret.AddToClassList("button__project-list-item-caret");
projectButton.hierarchy.Add(caret);
caret.clicked += () => OnCaretClicked(caret, collectionsContainer);
projectButton.clicked += () => OnCaretClicked(caret, collectionsContainer);
}

var collectionButton = new ActionButton();
collectionButton.quiet = true;
collectionButton.AddToClassList("button__project-list-item-collection");
collectionButton.label = collection.Name;
collectionButton.tooltip = collection.Name;

collectionButton.clicked += () => CollectionSelected?.Invoke(collection);
collectionsList.Add(collectionButton);
m_Collections.TryAdd(collection.Descriptor.Path, collectionButton);
}
}
}
Expand Down
Loading

0 comments on commit 19834cb

Please sign in to comment.