Skip to content
Snippets Groups Projects
Commit b4eb7e01 authored by Sylvain Renault's avatar Sylvain Renault
Browse files

Issue showing objects in Editor UI is solved (creator ID should never be Empty!).

Some improvmenents in the Graph editor (design, messages).
parent 3857ad31
No related branches found
No related tags found
No related merge requests found
Showing
with 98 additions and 36 deletions
......@@ -66,6 +66,7 @@ namespace ETSI.ARF.WorldStorage.UI
protected Vector2 scrollPos;
protected Color ori;
protected GUIStyle gsTest;
protected string saveText = "Save";
public void Update()
{
......
......@@ -189,6 +189,9 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
GUILayout.Label("Augmented Reality Framework", leftStyle);
GUILayout.Label("Copyright (C) 2024, ETSI (BSD 3-Clause License)", leftStyle);
//separator line
Rect rect = EditorGUILayout.GetControlRect(false, 1);
EditorGUI.DrawRect(rect, Color.gray);
switch (type)
{
......@@ -221,7 +224,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
//anchor icon
EditorGUILayout.BeginHorizontal();
Texture anchorImage = (Texture)AssetDatabase.LoadAssetAtPath("Assets/ETSI.ARF/ARF World Storage API/Images/anchor.png", typeof(Texture));
GUI.backgroundColor = Color.clear;
GUI.backgroundColor = WorldStorageWindow.arfColors[8];
GUILayout.Box(anchorImage, GUILayout.Width(40), GUILayout.Height(40));
//anchor label
......@@ -245,7 +248,8 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
GUI.backgroundColor = Color.clear;
GUILayout.BeginHorizontal();
GUILayout.Box(warningImage, GUILayout.Width(27), GUILayout.Height(27));
EditorGUILayout.LabelField("This element is not synchronized with the World Storage");
GUILayout.Label("This element is not synchronized with the World Storage!", EditorStyles.whiteBoldLabel);
GUILayout.EndHorizontal();
}
......@@ -260,7 +264,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
EditorGUILayout.LabelField("UUID ", EditorStyles.boldLabel, GUILayout.Width(50));
if (!SaveInfo.instance.nodePositions.ContainsKey(worldAnchor.UUID.ToString()))
{
EditorGUILayout.LabelField("none yet (element not yet saved in the server)");
EditorGUILayout.LabelField("None yet (element not yet saved in the server)");
}
else
{
......@@ -268,6 +272,8 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
}
EditorGUILayout.EndHorizontal();
GUI.backgroundColor = Color.white;
//name
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
......@@ -433,7 +439,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
//
//FOOTER
//
GUILayout.FlexibleSpace();
//GUILayout.FlexibleSpace();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
......@@ -490,10 +496,11 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
}
}
//save button
// save button
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Save"))
{
System.Guid _creator = Guid.NewGuid(); // System.Guid.Parse(WorldStorageWindow.WorldStorageWindowSingleton.worldStorageUser.UUID);
if (SaveInfo.instance.nodePositions.ContainsKey(worldAnchor.UUID.ToString()))
{
if (SaveInfo.instance.elemsToUpdate.Contains(worldAnchor.UUID.ToString()))
......@@ -510,6 +517,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
posX.Add(worldAnchorNode.GetPosition().x.ToString());
var posY = new Collection<String>();
posY.Add(worldAnchorNode.GetPosition().y.ToString());
WorldAnchor worldAnchor = worldAnchorNode.worldAnchor;
worldAnchor.KeyvalueTags["unityAuthoringPosX"] = posX;
worldAnchor.KeyvalueTags["unityAuthoringPosY"] = posY;
......@@ -560,7 +568,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
//trackable icon
EditorGUILayout.BeginHorizontal();
Texture trackImage = (Texture)AssetDatabase.LoadAssetAtPath("Assets/ETSI.ARF/ARF World Storage API/Images/trackable.png", typeof(Texture));
GUI.backgroundColor = Color.clear;
GUI.backgroundColor = WorldStorageWindow.arfColors[7];
GUILayout.Box(trackImage, GUILayout.Width(40), GUILayout.Height(40));
//trackable label
......@@ -584,7 +592,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
GUI.backgroundColor = Color.clear;
GUILayout.BeginHorizontal();
GUILayout.Box(warningImage, GUILayout.Width(27), GUILayout.Height(27));
EditorGUILayout.LabelField("This element is not synchronized with the World Storage");
GUILayout.Label("This element is not synchronized with the World Storage!", EditorStyles.whiteBoldLabel);
GUILayout.EndHorizontal();
}
......@@ -599,7 +607,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
EditorGUILayout.LabelField("UUID ", EditorStyles.boldLabel, GUILayout.Width(50));
if (!SaveInfo.instance.nodePositions.ContainsKey(trackable.UUID.ToString()))
{
EditorGUILayout.LabelField("none yet (element not yet saved in the server)");
EditorGUILayout.LabelField("None yet (element not yet saved in the server)");
}
else
{
......@@ -607,6 +615,8 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
}
EditorGUILayout.EndHorizontal();
GUI.backgroundColor = Color.white;
//name
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
......@@ -932,6 +942,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
TrackablePayload = new byte[64],
LocalCRS = localCRS,
Unit = UnitSystem.CM,
Confidence = 0,
TrackableSize = trackableSize,
KeyvalueTags = new KeyvalueTagList()
};
......@@ -1010,7 +1021,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
//world link icon
EditorGUILayout.BeginHorizontal();
Texture linkImage = (Texture)AssetDatabase.LoadAssetAtPath("Assets/ETSI.ARF/ARF World Storage API/Images/link.png", typeof(Texture));
GUI.backgroundColor = Color.clear;
GUI.backgroundColor = WorldStorageWindow.arfColors[9];
GUILayout.Box(linkImage, GUILayout.Width(40), GUILayout.Height(40));
//world link label
......@@ -1034,19 +1045,21 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
GUI.backgroundColor = Color.clear;
GUILayout.BeginHorizontal();
GUILayout.Box(warningImage, GUILayout.Width(27), GUILayout.Height(27));
EditorGUILayout.LabelField("This element is not synchronized with the World Storage");
GUILayout.Label("This element is not synchronized with the World Storage!", EditorStyles.whiteBoldLabel);
GUILayout.EndHorizontal();
}
//ELEMENT'S ATTRIBUTES
EditorGUI.BeginChangeCheck();
GUI.backgroundColor = Color.white;
//uuid
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("UUID ", EditorStyles.boldLabel, GUILayout.Width(50));
if (!SaveInfo.instance.linkIds.Contains(worldLink.UUID.ToString()))
{
EditorGUILayout.LabelField("none yet (element not yet saved in the server)");
EditorGUILayout.LabelField("None yet (element not yet saved in the server)");
}
else
{
......
......@@ -67,12 +67,14 @@ namespace ETSI.ARF.WorldStorage.UI
winSingleton.worldStorageUser = user;
if (!string.IsNullOrEmpty(UUID))
{
winSingleton.saveText = "Update";
winSingleton.UUID = UUID;
winSingleton.GetParams();
}
else
{
// Create new one
winSingleton.saveText = "Create";
winSingleton.AddObject();
}
}
......@@ -155,7 +157,7 @@ namespace ETSI.ARF.WorldStorage.UI
// ---------------------
EditorGUILayout.BeginHorizontal();
GUI.backgroundColor = WorldStorageWindow.arfColors[2];
if (GUILayout.Button("Save"))
if (GUILayout.Button(saveText))
{
Debug.Log("PUT Trackable");
......@@ -170,7 +172,6 @@ namespace ETSI.ARF.WorldStorage.UI
if (WorldStorageWindow.WorldStorageWindowSingleton != null)
{
WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables();
WorldStorageWindow.WorldStorageWindowSingleton.repaint = true;
}
Close();
});
......@@ -194,7 +195,6 @@ namespace ETSI.ARF.WorldStorage.UI
if (WorldStorageWindow.WorldStorageWindowSingleton != null)
{
WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables();
WorldStorageWindow.WorldStorageWindowSingleton.repaint = true;
}
Close();
});
......@@ -316,7 +316,6 @@ namespace ETSI.ARF.WorldStorage.UI
UUID = response.result;
UUID = UUID.Trim('"'); //Bugfix: remove " from server return value
WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables();
WorldStorageWindow.WorldStorageWindowSingleton.repaint = true;
});
}
......
......@@ -64,12 +64,14 @@ namespace ETSI.ARF.WorldStorage.UI
winSingleton.worldStorageUser = user;
if (!string.IsNullOrEmpty(UUID))
{
winSingleton.saveText = "Update";
winSingleton.UUID = UUID;
winSingleton.GetParams();
}
else
{
// Create new one
winSingleton.saveText = "Create";
winSingleton.AddObject();
}
}
......@@ -152,7 +154,7 @@ namespace ETSI.ARF.WorldStorage.UI
// ---------------------
EditorGUILayout.BeginHorizontal();
GUI.backgroundColor = WorldStorageWindow.arfColors[2];
if (GUILayout.Button("Save"))
if (GUILayout.Button(saveText))
{
Debug.Log("PUT World Anchor");
......
......@@ -122,6 +122,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
EditorGUI.BeginChangeCheck();
worldStorageServer = (WorldStorageServer)EditorGUILayout.ObjectField("World Storage Server", worldStorageServer, typeof(WorldStorageServer), false, GUILayout.Width(500));
worldStorageUser = (WorldStorageUser)EditorGUILayout.ObjectField("User", worldStorageUser, typeof(WorldStorageUser), false, GUILayout.Width(500));
if (EditorGUI.EndChangeCheck())
{
GraphEditorWindow.ResetWindow();
......@@ -143,6 +144,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
myGraph.style.top = Length.Percent(11);
myGraph.style.bottom = Length.Percent(5);
rootVisualElement.Add(myGraph);
Debug.Log("World Graph window initialized.");
}
catch (Exception e)
{
......@@ -163,7 +165,11 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows
leftStyle.alignment = TextAnchor.MiddleLeft;
GUILayout.Label("Augmented Reality Framework", leftStyle);
GUILayout.Label("Copyright (C) 2022, ETSI (BSD 3-Clause License)", leftStyle);
GUILayout.Label("Copyright (C) 2024, ETSI (BSD 3-Clause License)", leftStyle);
//separator line
Rect rect = EditorGUILayout.GetControlRect(false, 1);
EditorGUI.DrawRect(rect, Color.gray);
//reframe all elements to see them all
if (SaveInfo.instance.toReFrame && (twoFrames == 2))
......
......@@ -77,12 +77,14 @@ namespace ETSI.ARF.WorldStorage.UI
winSingleton.worldStorageUser = user;
if (!string.IsNullOrEmpty(UUID))
{
winSingleton.saveText = "Update";
winSingleton.UUID = UUID;
winSingleton.GetParams();
}
else
{
// Create new one
winSingleton.saveText = "Create";
winSingleton.AddObject();
}
}
......@@ -264,7 +266,7 @@ namespace ETSI.ARF.WorldStorage.UI
// ---------------------
EditorGUILayout.BeginHorizontal();
GUI.backgroundColor = WorldStorageWindow.arfColors[2];
if (GUILayout.Button("Save"))
if (GUILayout.Button(saveText))
{
Debug.Log("PUT World Link");
......@@ -333,7 +335,7 @@ namespace ETSI.ARF.WorldStorage.UI
}
else
{
EditorUtility.DisplayDialog("Selection", "Please select exactly 2 elements in the scene!", "OK");
EditorUtility.DisplayDialog("Selection", "Please select exactly 2 GameObject from typ Trackable(s) and/or WorldAnchor(s) in the scene!", "OK");
}
}
......@@ -470,7 +472,6 @@ namespace ETSI.ARF.WorldStorage.UI
UUID = response.result;
UUID = UUID.Trim('"'); //Bugfix: remove " from server return value
WorldStorageWindow.WorldStorageWindowSingleton.GetWorldLinks();
WorldStorageWindow.WorldStorageWindowSingleton.repaint = true;
});
}
......
......@@ -36,7 +36,8 @@ namespace ETSI.ARF.WorldStorage.UI
{
public class WorldStorageWindow : EditorWindow
{
static public WorldStorageWindow WorldStorageWindowSingleton;
static public WorldStorageWindow WorldStorageWindowSingleton;
static public string lastUserID = "8fb169e2-8910-4cd5-a8f9-b7abff38d013"; // dummy
[HideInInspector] public WorldStorageServer worldStorageServer;
[HideInInspector] public WorldStorageUser worldStorageUser;
......@@ -50,7 +51,7 @@ namespace ETSI.ARF.WorldStorage.UI
string state = "Unknow";
string vers = "Unknow";
public bool repaint = false;
private bool repaint = false;
private Vector2 scrollPos;
private Color ori;
private GUIStyle gsTest;
......@@ -74,9 +75,11 @@ namespace ETSI.ARF.WorldStorage.UI
new Color(.5f, .7f, 1f), // button graph window
new Color(.3f, .7f, 1f), // button generate prefab
new Color(1f, 1f, 0.3f), // button request
new Color(1f, 0.3f, 0.3f), // color for trackables
new Color(1f, 0.7f, 0f), // color for anchors
new Color(.66f, .4f, 1f) // color for links
new Color(1f, 0.3f, 0.3f), // 7/ color for trackables
new Color(1f, 0.7f, 0f), // 8/ color for anchors
new Color(.66f, .4f, 1f), // 9/ color for links
new Color(.66f, .66f, 66f), // color for light grey
new Color(.22f, .22f, 22f) // color for dark grey
};
......@@ -89,6 +92,7 @@ namespace ETSI.ARF.WorldStorage.UI
WorldStorageWindowSingleton.ping = response.result;
WorldStorageWindowSingleton.repaint = true;
});
WorldStorageWindow.lastUserID = WorldStorageWindowSingleton.worldStorageUser.UUID;
}
public void Update()
......@@ -245,7 +249,7 @@ namespace ETSI.ARF.WorldStorage.UI
#region Get all trackable objects
EditorGUILayout.Space();
GUI.backgroundColor = WorldStorageWindow.arfColors[0];
GUI.backgroundColor = WorldStorageWindow.arfColors[0];
if (GUILayout.Button("Request All"))
{
GetTrackables();
......@@ -315,7 +319,7 @@ namespace ETSI.ARF.WorldStorage.UI
EditorGUILayout.PropertyField(stringsProperty.GetArrayElementAtIndex(i));
string UUID = WorldStorageWindow.GetUUIDFromString(stringsProperty.GetArrayElementAtIndex(i).stringValue);
if (UUID == null) UUID = trackables[i]; // try this
if (UUID == null && i < trackables.Count) UUID = trackables[i]; // try this
if (GUILayout.Button("Edit...", EditorStyles.miniButtonLeft, buttonWidth))
{
Debug.Log("Open Trackable Window");
......@@ -407,7 +411,7 @@ namespace ETSI.ARF.WorldStorage.UI
EditorGUILayout.PropertyField(stringsProperty.GetArrayElementAtIndex(i));
string UUID = WorldStorageWindow.GetUUIDFromString(stringsProperty.GetArrayElementAtIndex(i).stringValue);
if (UUID == null) UUID = anchors[i]; // try this
if (UUID == null && i < anchors.Count) UUID = anchors[i]; // try this
if (GUILayout.Button("Edit...", EditorStyles.miniButtonLeft, buttonWidth))
{
Debug.Log("Open Anchor Window");
......@@ -497,7 +501,7 @@ namespace ETSI.ARF.WorldStorage.UI
EditorGUILayout.PropertyField(stringsProperty.GetArrayElementAtIndex(i));
string UUID = WorldStorageWindow.GetUUIDFromString(stringsProperty.GetArrayElementAtIndex(i).stringValue);
if (UUID == null) UUID = links[i]; // try this
if (UUID == null && i < links.Count) UUID = links[i]; // try this
if (GUILayout.Button("Edit...", EditorStyles.miniButtonLeft, buttonWidth))
{
Debug.Log("Open Link Window");
......@@ -575,11 +579,12 @@ namespace ETSI.ARF.WorldStorage.UI
public void GetTrackables()
{
// Get all objects
Debug.Log("Get all server objects");
Debug.Log("Get all server objects");
trackables.Clear();
repaint = true;
TrackableRequest.GetTrackablesAsync(worldStorageServer, (response) =>
{
Debug.Log("Get objects num = " + response.result.Count);
trackables.Clear();
foreach (var item in response.result)
{
if (filterByKeyValueTag != "")
......@@ -597,10 +602,11 @@ namespace ETSI.ARF.WorldStorage.UI
public void GetWorldAnchors()
{
// Get all objects
Debug.Log("Get all server objects");
Debug.Log("Get all server objects");
anchors.Clear();
repaint = true;
WorldAnchorRequest.GetWorldAnchorsAsync(worldStorageServer, (response) =>
{
anchors.Clear();
foreach (var item in response.result)
{
if (filterByKeyValueTag != "")
......@@ -618,10 +624,11 @@ namespace ETSI.ARF.WorldStorage.UI
public void GetWorldLinks()
{
// Get all objects
Debug.Log("Get all server objects");
Debug.Log("Get all server objects");
links.Clear();
repaint = true;
WorldLinkRequest.GetWorldLinksAsync(worldStorageServer, (response) =>
{
links.Clear();
foreach (var item in response.result)
{
links.Add(item.UUID.ToString());
......
fileFormatVersion: 2
guid: b7804462ad3c4834083d132ad9859cbd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8a1e3e7961eae84468e6ee20d5b09ffd, type: 3}
m_Name: User Demo
m_EditorClassIdentifier:
userName: Demo
company: ETSI
UUID: 8be8d5e3-9f7d-4f0f-9e45-549141dd9c0e
fileFormatVersion: 2
guid: 4dde5cf2754839a46aa36e0dd45bca65
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
Subproject commit fbe3790e81f4e5ce7d3837aaa28171f61fd9aec4
Subproject commit cebe3c24911db848f91ced30955be6bca4974a71
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment