From 00c4a43c3aff2d29139250147b208cbbfa9e13f0 Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:41:07 +0000 Subject: [PATCH] FE2 terms (#112) * FE2 terms * SendComponent * Removed terminology switching --- .../Components/SpeckleReceiverEditor.cs | 30 ++++++++++++++++--- .../Editor/Components/SpeckleSendEditor.cs | 28 ++++++++++++++--- .../Selection/StreamSelectionEditor.cs | 4 +-- .../Runtime/Components/SpeckleReceiver.cs | 8 ++--- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleReceiverEditor.cs b/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleReceiverEditor.cs index 5b77fa0..ff20003 100644 --- a/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleReceiverEditor.cs +++ b/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleReceiverEditor.cs @@ -1,4 +1,3 @@ -#nullable enable using System; using System.Collections.Concurrent; using System.Threading.Tasks; @@ -13,6 +12,12 @@ namespace Speckle.ConnectorUnity.Components.Editor [CustomEditor(typeof(SpeckleReceiver))] public class SpeckleReceiverEditor : UnityEditor.Editor { + private SerializedProperty _accountSelection; + private SerializedProperty _streamSelection; + private SerializedProperty _branchSelection; + private SerializedProperty _commitSelection; + +#nullable enable private static bool _generateAssets; private bool _foldOutStatus = true; private Texture2D? _previewImage; @@ -21,7 +26,11 @@ namespace Speckle.ConnectorUnity.Components.Editor { var speckleReceiver = (SpeckleReceiver)target; - DrawDefaultInspector(); + //Selection + EditorGUILayout.PropertyField(_accountSelection); + EditorGUILayout.PropertyField(_streamSelection, new GUIContent("Project")); + EditorGUILayout.PropertyField(_branchSelection, new GUIContent("Model")); + EditorGUILayout.PropertyField(_commitSelection, new GUIContent("Version")); //Preview image { @@ -64,8 +73,8 @@ namespace Speckle.ConnectorUnity.Components.Editor else if (userRequestedReceive) { var id = Progress.Start( - "Receiving Speckle data", - "Fetching commit data", + "Receiving Speckle Model", + "Fetching data from Speckle", Progress.Options.Sticky ); Progress.ShowDetails(); @@ -96,6 +105,19 @@ namespace Speckle.ConnectorUnity.Components.Editor public void OnEnable() { Init(); + + _accountSelection = serializedObject.FindProperty( + $"<{nameof(SpeckleReceiver.Account)}>k__BackingField" + ); + _streamSelection = serializedObject.FindProperty( + $"<{nameof(SpeckleReceiver.Stream)}>k__BackingField" + ); + _branchSelection = serializedObject.FindProperty( + $"<{nameof(SpeckleReceiver.Branch)}>k__BackingField" + ); + _commitSelection = serializedObject.FindProperty( + $"<{nameof(SpeckleReceiver.Commit)}>k__BackingField" + ); } public void Reset() diff --git a/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleSendEditor.cs b/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleSendEditor.cs index 0b6c862..68aee88 100644 --- a/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleSendEditor.cs +++ b/Packages/systems.speckle.speckle-unity/Editor/Components/SpeckleSendEditor.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; @@ -9,7 +10,6 @@ using UnityEngine; using UnityEngine.SceneManagement; using Component = UnityEngine.Component; -#nullable enable namespace Speckle.ConnectorUnity.Components.Editor { public enum SelectionFilter @@ -35,12 +35,32 @@ namespace Speckle.ConnectorUnity.Components.Editor [CanEditMultipleObjects] public class SpeckleSendEditor : UnityEditor.Editor { + private SerializedProperty _accountSelection; + private SerializedProperty _streamSelection; + private SerializedProperty _branchSelection; + +#nullable enable private SelectionFilter _selectedFilter = SelectionFilter.Children; + public void OnEnable() + { + _accountSelection = serializedObject.FindProperty( + $"<{nameof(SpeckleSender.Account)}>k__BackingField" + ); + _streamSelection = serializedObject.FindProperty( + $"<{nameof(SpeckleSender.Stream)}>k__BackingField" + ); + _branchSelection = serializedObject.FindProperty( + $"<{nameof(SpeckleSender.Branch)}>k__BackingField" + ); + } + public override async void OnInspectorGUI() { - //Draw events in a collapsed region - DrawDefaultInspector(); + //Selection + EditorGUILayout.PropertyField(_accountSelection); + EditorGUILayout.PropertyField(_streamSelection, new GUIContent("Project")); + EditorGUILayout.PropertyField(_branchSelection, new GUIContent("Model")); bool shouldSend = GUILayout.Button("Send!"); _selectedFilter = (SelectionFilter) @@ -79,7 +99,7 @@ namespace Speckle.ConnectorUnity.Components.Editor if (data["@objects"] is IList l && l.Count == 0) { - Debug.LogWarning($"Nothing to send", speckleSender); + Debug.LogWarning("Nothing to send", speckleSender); return null; } diff --git a/Packages/systems.speckle.speckle-unity/Editor/Wrappers/Selection/StreamSelectionEditor.cs b/Packages/systems.speckle.speckle-unity/Editor/Wrappers/Selection/StreamSelectionEditor.cs index 84ebc32..50877d9 100644 --- a/Packages/systems.speckle.speckle-unity/Editor/Wrappers/Selection/StreamSelectionEditor.cs +++ b/Packages/systems.speckle.speckle-unity/Editor/Wrappers/Selection/StreamSelectionEditor.cs @@ -46,7 +46,7 @@ namespace Speckle.ConnectorUnity.Wrappers.Selection.Editor details = new (string, Func)[] { - ("Stream id", s => s.id), + ("Project id", s => s.id), ("Description", s => s.description), ("Is Public", s => s.isPublic.ToString()), ("Role", s => s.role), @@ -88,7 +88,7 @@ namespace Speckle.ConnectorUnity.Wrappers.Selection.Editor { details = new (string, Func)[] { - ("Commit Id", s => s.id), + ("Version Id", s => s.id), ("Author Name", s => s.authorName), ("Created At", s => s.createdAt.ToString(CultureInfo.InvariantCulture)), ("Source Application", s => s.sourceApplication), diff --git a/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs b/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs index b9a32b8..eaa9caa 100644 --- a/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs +++ b/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs @@ -200,15 +200,15 @@ namespace Speckle.ConnectorUnity.Components { Client? selectedClient = Account.Client; client = - selectedClient ?? throw new InvalidOperationException("Invalid account selection"); + selectedClient ?? throw new InvalidOperationException("Invalid Speckle account selection"); Stream? selectedStream = Stream.Selected; stream = - selectedStream ?? throw new InvalidOperationException("Invalid stream selection"); + selectedStream ?? throw new InvalidOperationException("Invalid Speckle project selection"); Commit? selectedCommit = Commit.Selected; commit = - selectedCommit ?? throw new InvalidOperationException("Invalid commit selection"); + selectedCommit ?? throw new InvalidOperationException("Invalid Speckle version selection"); } /// @@ -445,7 +445,7 @@ namespace Speckle.ConnectorUnity.Components } #if UNITY_EDITOR - [ContextMenu("Open Speckle Stream in Browser")] + [ContextMenu("Open Speckle Model in Browser")] protected void OpenUrlInBrowser() { Uri url = GetSelectedUrl();