From a3687e09b8a3428cab2f13a63d50e77d81955dee Mon Sep 17 00:00:00 2001 From: jlacoche <jeremy.lacoche@orange.com> Date: Wed, 18 Dec 2024 16:55:58 +0100 Subject: [PATCH] Add Key Value edit in world graph editor, add encoding information in editor window --- Editor/Scripts/Windows/GraphEditorWindow.cs | 40 ++++++++++++++++++--- Editor/Scripts/Windows/TrackableWindow.cs | 23 ++++++++++-- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Editor/Scripts/Windows/GraphEditorWindow.cs b/Editor/Scripts/Windows/GraphEditorWindow.cs index 33d15ae..3066eba 100644 --- a/Editor/Scripts/Windows/GraphEditorWindow.cs +++ b/Editor/Scripts/Windows/GraphEditorWindow.cs @@ -29,6 +29,7 @@ using ETSI.ARF.WorldStorage.UI; using ETSI.ARF.WorldStorage.Editor.Graph; using ETSI.ARF.OpenAPI.WorldStorage; using System.Collections.ObjectModel; +using UnityEngine.UIElements; namespace ETSI.ARF.WorldStorage.Editor.Windows { @@ -56,9 +57,6 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows public Vector3 local_rot; public Vector3 local_pos; - //test - string m_newKey = ""; - List<string> m_newValues = new List<string>(); // UI stuffs private Vector2 scrollPos; @@ -699,9 +697,43 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows { floatVersion = EditorGUILayout.DelayedFloatField(0); } - trackable.TrackableEncodingInformation.Version = floatVersion.ToString(); + trackable.TrackableEncodingInformation.Version = floatVersion.ToString(System.Globalization.CultureInfo.InvariantCulture); EditorGUILayout.EndHorizontal(); + string toEdit = String.Empty; + string newKey = String.Empty; + string newValue = ""; + foreach(var item in trackable.KeyvalueTags) + { + string key = item.Key; + string value = item.Value[0]; + string oldKey = key; + string oldValue = value; + if (!key.Contains("unityAuthoringPos")) + { + key = EditorGUILayout.TextField("Key ", key); + value = EditorGUILayout.TextField("Value " , value); + if (key!= oldKey || oldValue != value) + { + newKey = key; + toEdit = oldKey; + newValue = value; + } + } + } + if (toEdit.Length > 0) + { + trackable.KeyvalueTags.Remove(toEdit); + trackable.KeyvalueTags.Add(newKey, new Collection<string> { newValue }); + } + + if (GUILayout.Button("Add Key Value")) + { + trackable.KeyvalueTags.Add("key" + trackable.KeyvalueTags.Count, new Collection<string>() { "test" }); + } + + + /*//trackable payload EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Trackable Payload ", EditorStyles.boldLabel, GUILayout.Width(140)); diff --git a/Editor/Scripts/Windows/TrackableWindow.cs b/Editor/Scripts/Windows/TrackableWindow.cs index 78e4223..8a10b7d 100644 --- a/Editor/Scripts/Windows/TrackableWindow.cs +++ b/Editor/Scripts/Windows/TrackableWindow.cs @@ -44,6 +44,8 @@ namespace ETSI.ARF.WorldStorage.UI string creatorUUID = System.Guid.Empty.ToString(); double confidence = 0f; TrackableType type = TrackableType.OTHER; + EncodingInformationStructureDataFormat format = EncodingInformationStructureDataFormat.ARCORE; + float versionEncoding = 1.01f; UnitSystem unit = UnitSystem.CM; Vector3 trackableSize; Vector3 localCRS_pos; @@ -237,6 +239,17 @@ namespace ETSI.ARF.WorldStorage.UI } } + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Trackable Information ", EditorStyles.boldLabel); + EditorGUILayout.EndHorizontal(); + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Format ", GUILayout.Width(50)); + format = (EncodingInformationStructureDataFormat)EditorGUILayout.EnumPopup(format); + EditorGUILayout.LabelField("Version ", GUILayout.Width(50)); + versionEncoding = EditorGUILayout.FloatField(versionEncoding); + EditorGUILayout.EndHorizontal(); + + // --------------------- // Keyvalues // --------------------- @@ -284,6 +297,10 @@ namespace ETSI.ARF.WorldStorage.UI localCRS_rot = Vector3.zero; } + EncodingInformationStructure encoding = obj.TrackableEncodingInformation; + format = encoding.DataFormat; + float.TryParse(encoding.Version, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out versionEncoding); + // --------------------- // Keyvalues // --------------------- @@ -331,10 +348,12 @@ namespace ETSI.ARF.WorldStorage.UI public override Trackable GenerateObject() { + + Debug.Log(" Coucou " +versionEncoding); EncodingInformationStructure trackableEncodingInformation = new EncodingInformationStructure() { - DataFormat = EncodingInformationStructureDataFormat.ARCORE, - Version = "1.0" + DataFormat = format , + Version = versionEncoding.ToString(System.Globalization.CultureInfo.InvariantCulture) }; Debug.Log("Created encoding information"); -- GitLab