From c4b08f3c79219b363cf5de6df8d8a3d64b654d45 Mon Sep 17 00:00:00 2001 From: Chafik Achache Date: Wed, 4 Sep 2024 13:51:37 -0400 Subject: [PATCH] Release 0.6.0 Develop @ceeaaf81367202f49a106657c1e6daf488cd8adc --- .../Assets/Build/ucrp_base_version.txt | 2 +- .../Assets/_Application/AssemblyInfo.cs | 2 +- .../FlyMode/Scripts/FlyOrbitController.cs | 10 +- .../Scripts/AppStates/AssetListState.cs | 35 +++- .../AppCamera/Runtime/Scripts/CameraProxy.cs | 2 +- .../Controllers/AssetInfoUIController.cs | 12 +- .../Controllers/AssetListController.cs | 15 +- .../Controllers/AssetListUIController.cs | 32 +--- .../Controllers/ProjectUIController.cs | 47 +++--- .../Scripts/Controllers/TextureController.cs | 120 ++++---------- .../Runtime/Scripts/ThumbnailPlaceholders.cs | 2 - .../TransformationWorkflowController.cs | 98 ----------- .../TransformationWorkflowController.cs.meta | 11 -- .../TransformationWorkflowUIController.cs | 156 ++++++++++-------- .../Scripts/UI/AssetInformationContainerUI.cs | 18 -- .../Runtime/Scripts/DeepLinkingController.cs | 19 +-- .../Runtime/Scripts/MeasureLinePersistence.cs | 1 - ReferenceProject/Packages/manifest.json | 4 +- ReferenceProject/Packages/packages-lock.json | 71 ++++---- .../ProjectSettings/ProjectSettings.asset | 10 +- 20 files changed, 252 insertions(+), 415 deletions(-) delete mode 100644 ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs delete mode 100644 ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs.meta diff --git a/ReferenceProject/Assets/Build/ucrp_base_version.txt b/ReferenceProject/Assets/Build/ucrp_base_version.txt index 26052838..4031a915 100644 --- a/ReferenceProject/Assets/Build/ucrp_base_version.txt +++ b/ReferenceProject/Assets/Build/ucrp_base_version.txt @@ -1 +1 @@ -ucrp-20240629 \ No newline at end of file +ucrp-20240725 \ No newline at end of file diff --git a/ReferenceProject/Assets/_Application/AssemblyInfo.cs b/ReferenceProject/Assets/_Application/AssemblyInfo.cs index e0ca1817..22c62fe3 100644 --- a/ReferenceProject/Assets/_Application/AssemblyInfo.cs +++ b/ReferenceProject/Assets/_Application/AssemblyInfo.cs @@ -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")] diff --git a/ReferenceProject/Assets/_Application/NavigationModes/FlyMode/Scripts/FlyOrbitController.cs b/ReferenceProject/Assets/_Application/NavigationModes/FlyMode/Scripts/FlyOrbitController.cs index 85eb3cee..34552eb4 100644 --- a/ReferenceProject/Assets/_Application/NavigationModes/FlyMode/Scripts/FlyOrbitController.cs +++ b/ReferenceProject/Assets/_Application/NavigationModes/FlyMode/Scripts/FlyOrbitController.cs @@ -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; @@ -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; @@ -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); } diff --git a/ReferenceProject/Assets/_Application/Scripts/AppStates/AssetListState.cs b/ReferenceProject/Assets/_Application/Scripts/AppStates/AssetListState.cs index d6b5f76e..25feb2f5 100644 --- a/ReferenceProject/Assets/_Application/Scripts/AppStates/AssetListState.cs +++ b/ReferenceProject/Assets/_Application/Scripts/AppStates/AssetListState.cs @@ -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; @@ -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 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(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 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; + } } } diff --git a/ReferenceProject/Assets/_Modules/AppCamera/Runtime/Scripts/CameraProxy.cs b/ReferenceProject/Assets/_Modules/AppCamera/Runtime/Scripts/CameraProxy.cs index 4fc4fd20..13ca7d7d 100644 --- a/ReferenceProject/Assets/_Modules/AppCamera/Runtime/Scripts/CameraProxy.cs +++ b/ReferenceProject/Assets/_Modules/AppCamera/Runtime/Scripts/CameraProxy.cs @@ -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); } diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetInfoUIController.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetInfoUIController.cs index 09d2d527..d1d4f9b2 100644 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetInfoUIController.cs +++ b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetInfoUIController.cs @@ -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 @@ -55,14 +54,6 @@ public class AssetInfoUIController : MonoBehaviour public event Action GenerateStreamableButtonClicked; public event Action NeedProjectInfo; - IAssetRepository m_AssetRepository; - - [Inject] - void Setup(IAssetRepository assetRepository) - { - m_AssetRepository = assetRepository; - } - void OnDestroy() { if (m_AssetPanel != null) @@ -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") diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListController.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListController.cs index 181830d8..05c1fee6 100644 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListController.cs +++ b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListController.cs @@ -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(); @@ -213,15 +211,10 @@ public async Task> 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(); - - 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(); diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListUIController.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListUIController.cs index ea9fd607..5016cef6 100644 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListUIController.cs +++ b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/AssetListUIController.cs @@ -16,19 +16,6 @@ namespace Unity.ReferenceProject.AssetList { - [Serializable] - class AllProjectResponse - { - public List 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; } @@ -398,24 +385,19 @@ async Task RefreshAsset() if (!m_AssetListController.IsCollectionSelected && m_AssetListController.SelectedProject != null) { m_RefreshCancellationTokenSource = new CancellationTokenSource(); - var collections = new List(); + + var collectionInfos = new List(); + 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(); - 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); } } diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/ProjectUIController.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/ProjectUIController.cs index 549117b3..425e93f2 100644 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/ProjectUIController.cs +++ b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/ProjectUIController.cs @@ -106,34 +106,33 @@ public async Task PopulateCollections(IEnumerable projects) var collectionsContainer = projectItem.Q("CollectionsContainer"); var collectionsList = collectionsContainer.Q("CollectionsList"); - var collections = new List(); - 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); } } } diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/TextureController.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/TextureController.cs index 861d6644..be2e2898 100644 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/TextureController.cs +++ b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/Controllers/TextureController.cs @@ -10,13 +10,16 @@ namespace Unity.ReferenceProject.AssetList { public static class TextureController { - static readonly int k_TimeoutDelay = 10000; - class TextureDownloadEntry { - public bool IsDownloading; + public bool IsDownloading = true; public Texture2D Texture2D; public readonly List> Listeners = new(); + + public TextureDownloadEntry(Action listener) + { + Listeners.Add(listener); + } } static Dictionary s_TextureCache = new(); @@ -29,45 +32,25 @@ public static async Task GetThumbnail(IAsset asset, int width, Action if (!s_TextureCache.TryGetValue(key, out var entry)) { // Create new download request - entry = new TextureDownloadEntry { IsDownloading = true }; - - lock (entry.Listeners) - { - entry.Listeners.Add(thumbnailReadyCallback); - } - + entry = new TextureDownloadEntry(thumbnailReadyCallback); s_TextureCache.Add(key, entry); try { var url = await asset.GetPreviewUrlAsync(CancellationToken.None); - if (url == null) - { - entry.IsDownloading = false; - thumbnailReadyCallback?.Invoke(null); - return; - } - - var resizedUrl = $"https://transformation.unity.com/api/images?url={Uri.EscapeDataString(url.ToString())}&width={width}"; - var taskTexture = DownloadTexture(resizedUrl); - if (await Task.WhenAny(taskTexture) == taskTexture) + if (url != null) { - entry.Texture2D = taskTexture.Result; - entry.IsDownloading = false; - } - else - { - entry.IsDownloading = false; - thumbnailReadyCallback?.Invoke(null); - Debug.LogError($"Timed out downloading thumbnail for asset {asset.Name}"); - return; + var resizedUrl = $"https://transformation.unity.com/api/images?url={Uri.EscapeDataString(url.ToString())}&width={width}"; + entry.Texture2D = await DownloadTexture(resizedUrl); } } catch (Exception e) { Debug.LogError($"Error getting thumbnail for {asset.Name}: {e}"); + } + finally + { OnTextureDownloaded(entry); - thumbnailReadyCallback?.Invoke(null); } } else if (entry.IsDownloading) @@ -77,13 +60,11 @@ public static async Task GetThumbnail(IAsset asset, int width, Action { entry.Listeners.Add(thumbnailReadyCallback); } - - return; } - - // Texture is ready - OnTextureDownloaded(entry); - thumbnailReadyCallback?.Invoke(entry.Texture2D); + else + { + thumbnailReadyCallback?.Invoke(entry.Texture2D); + } } public static void SetProjectIconUrl(string projectId, string iconUrl) @@ -93,7 +74,7 @@ public static void SetProjectIconUrl(string projectId, string iconUrl) public static async Task GetProjectIcon(string projectId, Action textureReadyCallback) { - if(!s_ProjectIconUrl.TryGetValue(projectId, out var iconUrl) || string.IsNullOrEmpty(iconUrl)) + if (!s_ProjectIconUrl.TryGetValue(projectId, out var iconUrl) || string.IsNullOrEmpty(iconUrl)) { textureReadyCallback?.Invoke(null); return; @@ -102,43 +83,20 @@ public static async Task GetProjectIcon(string projectId, Action text if (!s_TextureCache.TryGetValue(iconUrl, out var entry)) { // Create new download request - entry = new TextureDownloadEntry { IsDownloading = true }; - - lock (entry.Listeners) - { - entry.Listeners.Add(textureReadyCallback); - } - + entry = new TextureDownloadEntry(textureReadyCallback); s_TextureCache.Add(iconUrl, entry); try { - if (string.IsNullOrEmpty(iconUrl)) - { - entry.IsDownloading = false; - textureReadyCallback?.Invoke(null); - return; - } - - var taskTexture = DownloadTexture(iconUrl); - if (await Task.WhenAny(taskTexture) == taskTexture) - { - entry.Texture2D = taskTexture.Result; - entry.IsDownloading = false; - } - else - { - entry.IsDownloading = false; - textureReadyCallback?.Invoke(null); - Debug.LogError($"Timed out downloading project icon for {iconUrl}"); - return; - } + entry.Texture2D = await DownloadTexture(iconUrl); } catch (Exception e) { Debug.LogError($"Error getting project icon for {iconUrl}: {e}"); + } + finally + { OnTextureDownloaded(entry); - textureReadyCallback?.Invoke(null); } } else if (entry.IsDownloading) @@ -148,13 +106,11 @@ public static async Task GetProjectIcon(string projectId, Action text { entry.Listeners.Add(textureReadyCallback); } - - return; } - - // Texture is ready - OnTextureDownloaded(entry); - textureReadyCallback?.Invoke(entry.Texture2D); + else + { + textureReadyCallback?.Invoke(entry.Texture2D); + } } static readonly Color[] k_ProjectIconDefaultColors = @@ -181,18 +137,6 @@ public static Color GetProjectIconColor(string projectId) return k_ProjectIconDefaultColors[colorIndex]; } - static async Task GetUrl(IFile file) - { - var taskUrl = file.GetDownloadUrlAsync(CancellationToken.None); - if (await Task.WhenAny(taskUrl, Task.Delay(k_TimeoutDelay)) == taskUrl) - { - return taskUrl.Result; - } - - Debug.LogError($"Timed out getting thumbnail url for {file.Descriptor.Path}"); - return null; - } - static void OnTextureDownloaded(TextureDownloadEntry entry) { entry.IsDownloading = false; @@ -209,16 +153,20 @@ static void OnTextureDownloaded(TextureDownloadEntry entry) static async Task DownloadTexture(string url) { using var uwr = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET); - uwr.downloadHandler = new DownloadHandlerTexture(); + uwr.disposeDownloadHandlerOnDispose = true; + + var textureHandler = new DownloadHandlerTexture(); + uwr.downloadHandler = textureHandler; var operation = uwr.SendWebRequest(); - while (!operation.isDone) + // Ensure that the operation and texture download are completed before attempting to use the texture + while (!operation.isDone || !textureHandler.isDone) { await Task.Yield(); } - return DownloadHandlerTexture.GetContent(uwr); + return textureHandler.texture; } } } diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/ThumbnailPlaceholders.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/ThumbnailPlaceholders.cs index 225b104d..7164b3d8 100644 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/ThumbnailPlaceholders.cs +++ b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/ThumbnailPlaceholders.cs @@ -39,8 +39,6 @@ void OnEnable() } } - public List ThumbnailsPlaceholder => m_ThumbnailsPlaceholder; - public Texture2D GetDefaultThumbnail(AssetType assetType) { if (m_TextureByAssetType.TryGetValue(assetType, out var placeholder)) diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs deleted file mode 100644 index 59da647e..00000000 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Unity.Cloud.Assets; -using Unity.Cloud.Common; -using UnityEngine; - -namespace Unity.ReferenceProject.AssetList -{ - [Serializable] - class TransformationData - { - public string id { get; set; } = null; - public string userId { get; set; } = null; - public string assetId { get; set; } = null; - public string assetVersion { get; set; } = null; - public string inputDatasetId { get; set; } = null; - public List inputFiles { get; set; } = null; - public string outputDatasetId { get; set; } = null; - public string linkDatasetId { get; set; } = null; - public string workflowType { get; set; } = null; - public string jobId { get; set; } = null; - public string status { get; set; } = null; - public string errorMessage { get; set; } = null; - public string progress { get; set; } = null; - - public bool IsRunning() - { - return status?.ToLower() == "running"; - } - } - - public class TransformationWorkflowController - { - readonly IServiceHttpClient m_ServiceHttpClient; - readonly IServiceHostResolver m_ServiceHostResolver; - - public TransformationWorkflowController(IServiceHttpClient serviceHttpClient, IServiceHostResolver serviceHostResolver) - { - m_ServiceHttpClient = serviceHttpClient; - m_ServiceHostResolver = serviceHostResolver; - } - - public async Task StartTransformation(IDataset dataset, string file) - { - var descriptor = dataset.Descriptor; - var url = ConstructUrl($"projects/{descriptor.ProjectId}/assets/{descriptor.AssetId}/versions/{descriptor.AssetVersion}/datasets/{descriptor.DatasetId}/transformations/start/3d-data-streaming"); - - try - { - using var httpRequestMessage = new HttpRequestMessage(); - httpRequestMessage.Method = HttpMethod.Post; - httpRequestMessage.RequestUri = new Uri(url); - - var body = "{\"inputFiles\":[\"" + file + "\"]}"; - - httpRequestMessage.Content = new StringContent(body, Encoding.UTF8, "application/json"); - - using var response = await m_ServiceHttpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead); - response.EnsureSuccessStatusCode(); - } - catch (Exception e) - { - Debug.LogException(e); - throw; - } - } - - public async Task CurrentTransformations(ProjectId projectId) - { - var url = ConstructUrl($"projects/{projectId}/transformations"); - - try - { - using var httpRequestMessage = new HttpRequestMessage(); - httpRequestMessage.Method = HttpMethod.Get; - httpRequestMessage.RequestUri = new Uri(url); - - using var response = await m_ServiceHttpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead); - response.EnsureSuccessStatusCode(); - - return await response.Content.ReadAsStringAsync(); - } - catch (Exception e) - { - Debug.LogException(e); - throw; - } - } - - string ConstructUrl(string path) - { - return $"{m_ServiceHostResolver.GetResolvedAddress()}/assets/v1/{path}"; - } - } -} diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs.meta b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs.meta deleted file mode 100644 index fa5be5a1..00000000 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowController.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 69188648ddf586641a78726cacd6d312 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowUIController.cs b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowUIController.cs index 25d52f90..1f2e2073 100644 --- a/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowUIController.cs +++ b/ReferenceProject/Assets/_Modules/AssetList/Runtime/Scripts/TransformationWorkflow/TransformationWorkflowUIController.cs @@ -4,10 +4,8 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Newtonsoft.Json; using Unity.AppUI.UI; using Unity.Cloud.Assets; -using Unity.Cloud.Common; using Unity.ReferenceProject.Common; using Unity.ReferenceProject.DataStreaming; using Unity.ReferenceProject.Messaging; @@ -25,10 +23,8 @@ public class TransformationWorkflowUIController : MonoBehaviour [SerializeField] bool m_HideNonSourceDatasets = true; - + static readonly string k_SourceDatasetName = "Source"; // This is a convention in the Asset Manager - - TransformationWorkflowController m_TransformationWorkflowController; IDataset m_SelectedDataset; string m_SelectedFile; @@ -39,7 +35,7 @@ public class TransformationWorkflowUIController : MonoBehaviour AlertDialog m_Dialog; Label m_AssetName; - + Dropdown m_DatasetDropdown; Dropdown m_FilesDropdown; @@ -47,14 +43,12 @@ public class TransformationWorkflowUIController : MonoBehaviour Coroutine m_RefreshTransformationState; MessageUIHelper m_MessageUIHelper; - static readonly float k_RefreshTransformationsStateInterval = 2.0f; [Inject] - public void Setup(IServiceHttpClient serviceHttpClient, IServiceHostResolver serviceHostResolver, IMainUIPanel mainUIPanel, IAppMessaging appMessaging) + public void Setup(IMainUIPanel mainUIPanel, IAppMessaging appMessaging) { - m_TransformationWorkflowController = new TransformationWorkflowController(serviceHttpClient, serviceHostResolver); m_MainUIPanel = mainUIPanel; m_AppMessaging = appMessaging; } @@ -94,34 +88,34 @@ enum MessageType IsRunning, IsOverride } - + class MessageUIHelper { readonly VisualElement m_TransformationMessageHelp; readonly VisualElement m_TransformationMessageIsRunning; readonly VisualElement m_TransformationMessageIsOverride; - + public MessageUIHelper(VisualElement root) { m_TransformationMessageHelp = root.Q("TransformationHelpMessage"); m_TransformationMessageIsRunning = root.Q("TransformationIsRunningMessage"); m_TransformationMessageIsOverride = root.Q("TransformationIsOverrideMessage"); } - + public void ShowMessage(MessageType messageType) { Utils.SetVisible(m_TransformationMessageHelp, messageType == MessageType.Help); Utils.SetVisible(m_TransformationMessageIsRunning, messageType == MessageType.IsRunning); Utils.SetVisible(m_TransformationMessageIsOverride, messageType == MessageType.IsOverride); - } + } } - + AlertDialog CreateDialog() { var root = m_VisualTreeAsset.Instantiate(); m_AssetName = root.Q