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

Merge branch 'feature/withSubmodule' into 'main'

Feature/with submodule

See merge request !1
parents a0c9e4ad 10f33679
No related branches found
No related tags found
2 merge requests!2Major structural and design changes on GUI, classes, parameters...,!1Feature/with submodule
Showing
with 658 additions and 531 deletions
[submodule "Packages/unity-world-storage-package"]
path = Packages/unity-world-storage-package
url = https://labs.etsi.org/rep/arf/world-storage-api-helpers/unity-world-storage-package.git
...@@ -7,7 +7,7 @@ using UnityEditor; ...@@ -7,7 +7,7 @@ using UnityEditor;
using UnityEditor.Experimental.GraphView; using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements; using UnityEngine.UIElements;
using UnityEditor.UIElements; using UnityEditor.UIElements;
using ETSI.ARF.WorldStorage.RESTful; using ETSI.ARF.WorldStorage.REST;
#if USING_OPENAPI_GENERATOR #if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
...@@ -23,13 +23,14 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -23,13 +23,14 @@ namespace ETSI.ARF.WorldStorage.UI
public class GraphWindow : EditorWindow public class GraphWindow : EditorWindow
{ {
[HideInInspector] public WorldStorageSettings worldStorageSettings; [HideInInspector] public WorldStorageServer worldStorageSettings;
[SerializeField] public List<string> trackables = new List<string>(); [SerializeField] public List<string> trackables = new List<string>();
bool groupEnabled; bool groupEnabled;
string uid = System.Guid.Empty.ToString(); string uid = System.Guid.Empty.ToString();
string customName = "NotDefined";
string creatorUid = System.Guid.Empty.ToString(); string creatorUid = System.Guid.Empty.ToString();
string type = "Unknow"; string type = "Unknow";
string unit = "Unknow"; string unit = "Unknow";
...@@ -42,8 +43,8 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -42,8 +43,8 @@ namespace ETSI.ARF.WorldStorage.UI
private ARFGraphView myGraph; private ARFGraphView myGraph;
[MenuItem("[ ISG-ARF ]/Graph Editor")] [MenuItem("ARFWorldStorage/Graph Editor")]
public static void ShowWindow()//WorldStorageSettings ws) public static void ShowWindow()//WorldStorageServer ws)
{ {
GraphWindow win = EditorWindow.GetWindow(typeof(GraphWindow), false, WorldStorageWindow.winName) as GraphWindow; GraphWindow win = EditorWindow.GetWindow(typeof(GraphWindow), false, WorldStorageWindow.winName) as GraphWindow;
//win.worldStorageSettings = ws; //win.worldStorageSettings = ws;
...@@ -117,6 +118,7 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -117,6 +118,7 @@ namespace ETSI.ARF.WorldStorage.UI
//graph.Draw(); //graph.Draw();
} }
/*
void DrawTrackableStuffs()// Trackable trackable) void DrawTrackableStuffs()// Trackable trackable)
{ {
GUILayout.BeginVertical("AR Trackable", gsTest); GUILayout.BeginVertical("AR Trackable", gsTest);
...@@ -133,9 +135,9 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -133,9 +135,9 @@ namespace ETSI.ARF.WorldStorage.UI
if (GUILayout.Button("Get Parameters")) if (GUILayout.Button("Get Parameters"))
{ {
Trackable t = RESTfulTrackableRequest.GetTrackable(worldStorageSettings, uid); Trackable t = RESTfulTrackableRequest.GetTrackable(worldStorageSettings, uid);
creatorUid = t.CreatorUID.ToString(); creatorUid = t.CreatorUUID.ToString();
type = t.GetType().ToString(); type = t.GetType().ToString();
unit = t.UnitSystem.ToString(); unit = t.Unit.ToString();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
...@@ -177,18 +179,18 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -177,18 +179,18 @@ namespace ETSI.ARF.WorldStorage.UI
{ {
Debug.Log("PostAddTrackable"); Debug.Log("PostAddTrackable");
if (string.IsNullOrEmpty(uid) || uid == "0") uid = System.Guid.Empty.ToString(); if (string.IsNullOrEmpty(uid) || uid == "0") uid = System.Guid.Empty.ToString();
Trackable t = RESTfulTrackableRequest.TrackableFromStrings(uid, worldStorageSettings.creatorUID); Trackable t = RESTfulTrackableRequest.TrackableFromStrings(uid, cus, worldStorageSettings.creatorUID);
RESTfulTrackableRequest.PostAddTrackable(worldStorageSettings, t); RESTfulTrackableRequest.PostAddTrackable(worldStorageSettings, t);
WorldStorageWindow.WorldStorageWindowSingleton.UpdateList(); WorldStorageWindow.WorldStorageWindowSingleton.UpdateList();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
uid = t.UID.ToString(); uid = t.UUID.ToString();
type = t.GetType().ToString(); type = t.GetType().ToString();
unit = t.UnitSystem.ToString(); unit = t.Unit.ToString();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
} }
*/
} }
} }
\ No newline at end of file
// Source:
// https://gist.github.com/thelastpointer/c52c4b1f147dc47961798e39e3a7ea10
/*
EditorGraph -- quickly draw graphs in the inspector.
Place this in a folder named 'Editor'.
*/
/*
USAGE:
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
TLP.Editor.EditorGraph graph = new TLP.Editor.EditorGraph(0, -1, 10, 1, "Just a sin wave", 100);
graph.AddFunction(x => Mathf.Sin(x));
graph.Draw();
}
MORE COMPLICATED USAGE:
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
TLP.Editor.EditorGraph graph = new TLP.Editor.EditorGraph(0, -1, 10, 1, "Another sin wave!", 100);
graph.AddFunction(x => Mathf.Sin(x));
// Another function with a different color
graph.AddFunction(x => Mathf.Sin(x * 2), Color.cyan);
// Do something when the graph is clicked on
graph.AddClickEvent((x, y) => Debug.LogFormat("You clicked at {0};{1}. The sin value for that is {2}", x, y, Mathf.Sin(x)));
// Edit some colors...
graph.Colors.Background = new Color(0.2f, 0.2f, 0.2f, 1f);
// Add two vertical lines
graph.AddLineX(Mathf.PI);
graph.AddLineX(Mathf.PI * 2);
// Add a horizontal line with different color
graph.AddLineY(0, Color.gray);
graph.Draw();
}
*/
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace TLP.Editor
{
/// <summary>
/// Draw graphs in the inspector.
/// </summary>
public class EditorGraph
{
/// <summary>
/// Title of the graph.
/// </summary>
public string Title;
/// <summary>
/// Vertical helper line distance, in graph units (a vertical line will be drawn every X units, starting at minimum X). Set 0 to disable.
/// </summary>
/// <remarks>There will be at most one line per every two pixels.</remarks>
public float GridLinesX = 0;
/// <summary>
/// Horizontal helper line distance, in graph units (a horizontal line will be drawn every Y units, starting at minimum Y). Set 0 to disable.
/// </summary>
/// <remarks>There will be at most one line per every two pixels.</remarks>
public float GridLinesY = 0;
/// <summary>
/// Color settings.
/// </summary>
public GraphColors Colors;
/// <summary>
/// Resolution of the graph -- how many points are evaluated and rendered for custom functions.
/// </summary>
public int GraphResolution = 48;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="_minX">Minimum X value in graph units.</param>
/// <param name="_minY">Minimum Y value in graph units.</param>
/// <param name="_maxX">Maximum X value in graph units.</param>
/// <param name="_maxY">Maximum Y value in graph units.</param>
/// <param name="_title">Title of the graph (optional).</param>
/// <param name="_title">Resolution of the graphs (how many points are evaluated for each custom function).</param>
public EditorGraph(float _minX, float _minY, float _maxX, float _maxY, string _title = "", int _resolution = 48)
{
if (_minX >= _maxX)
throw new System.ArgumentException("Editor graph: minimum X value must be greater than maximum!", "_minX");
if (_minY >= _maxY)
throw new System.ArgumentException("Editor graph: minimum Y value must be greater than maximum!", "_minY");
minX = _minX;
maxX = _maxX;
minY = _minY;
maxY = _maxY;
rangeX = maxX - minX;
rangeY = maxY - minY;
Title = _title;
GraphResolution = _resolution;
// Default graph colors
Colors = new GraphColors
{
Background = new Color(0.15f, 0.15f, 0.15f, 1f),
Outline = new Color(0.15f, 0.15f, 0.15f, 1f),
GridLine = new Color(0.5f, 0.5f, 0.5f),
Function = Color.red,
CustomLine = Color.white
};
}
/// <summary>
/// Colors used to draw the graph.
/// </summary>
public struct GraphColors
{
/// <summary>
/// Background color.
/// </summary>
public Color Background;
/// <summary>
/// Outline color for the graph.
/// </summary>
public Color Outline;
/// <summary>
/// Helper line color.
/// </summary>
public Color GridLine;
/// <summary>
/// Default color for custom functions.
/// </summary>
public Color Function;
/// <summary>
/// Default color for custom lines.
/// </summary>
public Color CustomLine;
}
#region Public functions
/// <summary>
/// Draw the graph with the default size (128x80).
/// </summary>
public void Draw()
{
Draw(128, 80);
}
/// <summary>
/// Draw the graph with the specified minimum size.
/// </summary>
/// <param name="width">Minimum width of the graph in pixels.</param>
/// <param name="height">Minimum height of the graph in pixels.</param>
public void Draw(float width, float height)
{
// Get rect
if (!string.IsNullOrEmpty(Title))
{
using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
GUILayout.Label(Title);
}
// Title
using (new GUILayout.HorizontalScope())
{
GUILayout.Space(EditorGUI.indentLevel * 15f);
rect = GUILayoutUtility.GetRect(width, height);
}
// Handle MouseDown events
if (Event.current.type == EventType.MouseDown)
{
if (rect.Contains(Event.current.mousePosition))
{
Vector2 mousePos = (Event.current.mousePosition - rect.position);
Vector2 unitPos = new Vector2(
mousePos.x / rect.width * rangeX + minX,
(1f - (mousePos.y / rect.height)) * rangeY + minY
);
foreach (var e in clickEvents)
e(unitPos.x, unitPos.y);
}
}
// Only continue if we're repainting the graph
if (Event.current.type != EventType.Repaint)
return;
// Background
DrawRect(minX, minY, maxX, maxY, Colors.Background, Colors.Outline);
// Vertical helper lines
if (GridLinesX > 0)
{
float multiplier = 1;
while ((rangeX / (GridLinesX * multiplier)) > (rect.width / 2f))
multiplier *= 2;
for (float x = minX; x <= maxX; x += GridLinesX * multiplier)
DrawLine(x, minY, x, maxY, Colors.GridLine, 1);
}
// Horizontal helper lines
if (GridLinesY > 0)
{
float multiplier = 1;
while ((rangeY / (GridLinesY * multiplier)) > (rect.height / 2f))
multiplier *= 2;
for (float y = minY; y <= maxY; y += GridLinesY * multiplier)
DrawLine(minX, y, maxX, y, Colors.GridLine, 1);
}
// Vertical lines
foreach (var line in linesX)
{
DrawLine(line.Position, minY, line.Position, maxY, line.Color, 2);
}
// Horizontal lines
foreach (var line in linesY)
{
DrawLine(minX, line.Position, maxX, line.Position, line.Color, 2);
}
// Check if the vertex buffer is of the correct size
int res = (GraphResolution <= 0 ? 48 : GraphResolution);
if ((curveVertices == null) || (curveVertices.Length != res))
curveVertices = new Vector3[res];
// Evaluate all functions
foreach (var func in functions)
{
var vcount = 0;
while (vcount < res)
{
var x = this.rangeX * vcount / (res - 1);
var y = func.Function(x);
if ((y > minY) && (y < maxY))
{
curveVertices[vcount++] = UnitToGraph(x, y);
}
else
{
if (vcount > 1)
{
// Extend the last segment to the top edge of the rect.
var v1 = curveVertices[vcount - 2];
var v2 = curveVertices[vcount - 1];
var clip = (rect.y - v1.y) / (v2.y - v1.y);
curveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
}
break;
}
}
if (vcount > 1)
{
Handles.color = func.Color;
Handles.DrawAAPolyLine(2.0f, vcount, curveVertices);
}
}
}
/// <summary>
/// Add a custom function to the graph using the default color.
/// </summary>
/// <param name="func">A function that evaluates the graph at a given position (graph units).</param>
public void AddFunction(GraphFunction func)
{
AddFunction(func, Colors.Function);
}
/// <summary>
/// Add a custom function to the graph.
/// </summary>
/// <param name="func">A function that evaluates the graph at a given position (graph units).</param>
/// <param name="color">Color of the rendered function.</param>
public void AddFunction(GraphFunction func, Color color)
{
foreach (var pair in functions)
{
if (pair.Function == func)
return;
}
functions.Add(new FunctionColorPair { Function = func, Color = color });
}
/// <summary>
/// Register a function that handles click events. Arguments are passed as graph units.
/// </summary>
/// <param name="e">Function to call when the user clicks on the graph.</param>
public void AddClickEvent(MouseEvent e)
{
if (!clickEvents.Contains(e))
clickEvents.Add(e);
}
/// <summary>
/// Add a vertical line with the default color.
/// </summary>
/// <param name="value">Position of the line in graph units.</param>
public void AddLineX(float value)
{
AddLineX(value, Colors.CustomLine);
}
/// <summary>
/// Add a vertical line.
/// </summary>
/// <param name="value">Position of the line in graph units.</param>
/// <param name="color">Color of the line.</param>
public void AddLineX(float value, Color color)
{
foreach (var pair in linesX)
{
if (pair.Position == value)
return;
}
linesX.Add(new LineColorPair { Position = value, Color = color });
}
/// <summary>
/// Add a horizontal line with the default color.
/// </summary>
/// <param name="value">Position of the line in graph units.</param>
public void AddLineY(float value)
{
AddLineY(value, Colors.CustomLine);
}
/// <summary>
/// Add a horizontal line.
/// </summary>
/// <param name="value">Position of the line in graph units.</param>
/// <param name="color">Color of the line.</param>
public void AddLineY(float value, Color color)
{
foreach (var pair in linesY)
{
if (pair.Position == value)
return;
}
linesY.Add(new LineColorPair { Position = value, Color = color });
}
#endregion
/// <summary>
/// Custom function delegate. This works in graph units.
/// </summary>
/// <param name="x">Input value, eg. where the function is evaluated.</param>
/// <returns>The evaluated value at position x.</returns>
public delegate float GraphFunction(float x);
/// <summary>
/// Mouse click delegate.
/// </summary>
/// <param name="x">X position of the click, in graph units.</param>
/// <param name="y">Y position of the click, in graph units.</param>
public delegate void MouseEvent(float x, float y);
#region Internal state
// Vertex buffers
Vector3[] rectVertices = new Vector3[4];
Vector3[] lineVertices = new Vector3[2];
Vector3[] curveVertices;
List<FunctionColorPair> functions = new List<FunctionColorPair>();
List<LineColorPair> linesX = new List<LineColorPair>();
List<LineColorPair> linesY = new List<LineColorPair>();
List<MouseEvent> clickEvents = new List<MouseEvent>();
float minX, maxX, minY, maxY;
Rect rect;
float rangeX = 10;
float rangeY = 10;
struct FunctionColorPair
{
public GraphFunction Function;
public Color Color;
}
struct LineColorPair
{
public float Position;
public Color Color;
}
#endregion
#region Helper functions
Vector3 UnitToGraph(float x, float y)
{
x = Mathf.Lerp(rect.x, rect.xMax, (x - minX) / rangeX);
y = Mathf.Lerp(rect.yMax, rect.y, (y - minY) / rangeY);
return new Vector3(x, y, 0);
}
float UnitToGraphX(float x)
{
return Mathf.Lerp(rect.x, rect.xMax, (x - minX) / rangeX);
}
float UnitToGraphY(float y)
{
return Mathf.Lerp(rect.yMax, rect.y, (y - minY) / rangeY);
}
void DrawLine(float x1, float y1, float x2, float y2, Color color, float width)
{
lineVertices[0] = UnitToGraph(x1, y1);
lineVertices[1] = UnitToGraph(x2, y2);
Handles.color = color;
Handles.DrawAAPolyLine(width, lineVertices);
}
void DrawRect(float x1, float y1, float x2, float y2, Color fill, Color line)
{
rectVertices[0] = UnitToGraph(x1, y1);
rectVertices[1] = UnitToGraph(x2, y1);
rectVertices[2] = UnitToGraph(x2, y2);
rectVertices[3] = UnitToGraph(x1, y2);
Handles.DrawSolidRectangleWithOutline(rectVertices, fill, line);
}
#endregion
}
}
\ No newline at end of file
fileFormatVersion: 2 fileFormatVersion: 2
guid: efec94a96917ef946ab027baa62bc0bc guid: fbbff3217b2a8cd428764d83150c7b22
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
...@@ -4,20 +4,17 @@ ...@@ -4,20 +4,17 @@
// (C) 2022 // (C) 2022
// //
// Development "World Storage", data management, authoring tools // Development "World Storage", data management, authoring tools
// // Date: June 2022
// Authors:
// - Sylvain Renault (Fraunhofer HHI)
//
// Date: Feb. 2022
// //
#define USING_OPENAPI_GENERATOR // alt. is Swagger #define USING_OPENAPI_GENERATOR // alt. is Swagger
//#define isDEBUG
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using ETSI.ARF.WorldStorage.RESTful; using ETSI.ARF.WorldStorage.REST;
#if USING_OPENAPI_GENERATOR #if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
...@@ -32,14 +29,16 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -32,14 +29,16 @@ namespace ETSI.ARF.WorldStorage.UI
{ {
public class TrackableWindow : EditorWindow public class TrackableWindow : EditorWindow
{ {
[HideInInspector] public WorldStorageSettings worldStorageSettings; [HideInInspector] public WorldStorageServer worldStorageServer;
[HideInInspector] public WorldStorageUser worldStorageUser;
[SerializeField] public List<string> trackables = new List<string>(); [SerializeField] public List<string> trackables = new List<string>();
bool groupEnabled; bool groupEnabled;
string uid = System.Guid.Empty.ToString(); string UUID = System.Guid.Empty.ToString();
string creatorUid = System.Guid.Empty.ToString(); string customName = "NotDefined";
string creatorUUID = System.Guid.Empty.ToString();
string type = "Unknow"; string type = "Unknow";
string unit = "Unknow"; string unit = "Unknow";
Vector2Int dim; Vector2Int dim;
...@@ -49,10 +48,11 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -49,10 +48,11 @@ namespace ETSI.ARF.WorldStorage.UI
private Color ori; private Color ori;
private GUIStyle gsTest; private GUIStyle gsTest;
public static void ShowWindow(WorldStorageSettings ws) public static void ShowWindow(WorldStorageServer ws, WorldStorageUser user)
{ {
TrackableWindow win = EditorWindow.GetWindow(typeof(TrackableWindow), false, WorldStorageWindow.winName) as TrackableWindow; TrackableWindow win = EditorWindow.GetWindow(typeof(TrackableWindow), false, WorldStorageWindow.winName) as TrackableWindow;
win.worldStorageSettings = ws; win.worldStorageServer = ws;
win.worldStorageUser = user;
} }
public TrackableWindow() public TrackableWindow()
...@@ -72,7 +72,7 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -72,7 +72,7 @@ namespace ETSI.ARF.WorldStorage.UI
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true));
WorldStorageWindow.DrawCopyright(); WorldStorageWindow.DrawCopyright();
DrawTrackableStuffs();// currentTrackable); DrawTrackableStuffs();
EditorGUILayout.EndScrollView(); EditorGUILayout.EndScrollView();
...@@ -86,21 +86,32 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -86,21 +86,32 @@ namespace ETSI.ARF.WorldStorage.UI
{ {
GUILayout.BeginVertical("AR Trackable", gsTest); GUILayout.BeginVertical("AR Trackable", gsTest);
// //
GUILayout.Label("Server: " + worldStorageSettings.serverName, EditorStyles.whiteLargeLabel); GUILayout.Label("Server: " + worldStorageServer.serverName, EditorStyles.whiteLargeLabel);
GUILayout.Label("Creator UID: " + creatorUid, EditorStyles.miniLabel); // readonly GUILayout.Label("User: " + worldStorageUser.userName, EditorStyles.whiteLargeLabel);
EditorGUILayout.Space(); EditorGUILayout.Space();
//GUILayout.BeginHorizontal(); //GUILayout.BeginHorizontal();
uid = EditorGUILayout.TextField("UID (0 = new one)", uid); customName = EditorGUILayout.TextField("Name of Trackable", customName);
#if isDEBUG
GUILayout.Label("UUID: " + UUID, EditorStyles.miniLabel); // readonly
GUILayout.Label("Creator UID: " + creatorUUID, EditorStyles.miniLabel); // readonly
#endif
EditorGUILayout.Space(); EditorGUILayout.Space();
GUI.backgroundColor = WorldStorageWindow.arfColors[1]; GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Get Parameters")) if (GUILayout.Button("Get Parameters"))
{ {
Trackable t = RESTfulTrackableRequest.GetTrackable(worldStorageSettings, uid); if (!customName.Contains("[")) UUID = customName;
creatorUid = t.CreatorUID.ToString(); else
type = t.GetType().ToString(); {
unit = t.UnitSystem.ToString(); // extract the UUID
UUID = customName.Split('[', ']')[1];
}
Trackable obj = TrackableRequest.GetTrackable(worldStorageServer, UUID);
customName = obj.Name;
creatorUUID = obj.CreatorUUID.ToString();
type = obj.TrackableType.ToString();
unit = obj.Unit.ToString();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
...@@ -123,41 +134,95 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -123,41 +134,95 @@ namespace ETSI.ARF.WorldStorage.UI
// //
GUILayout.EndVertical(); GUILayout.EndVertical();
// ###########################################################
GUI.backgroundColor = WorldStorageWindow.arfColors[2];
if (GUILayout.Button("Create/Update Trackable"))
{
Debug.Log("PostAddTrackable");
if (string.IsNullOrEmpty(UUID) || UUID == "0") UUID = System.Guid.Empty.ToString();
Trackable obj = GenerateTrackable(UUID, customName, worldStorageUser.UUID);
TrackableRequest.AddTrackable(worldStorageServer, obj);
WorldStorageWindow.WorldStorageWindowSingleton.UpdateListTrackables();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
UUID = obj.UUID.ToString();
customName = obj.Name;
type = obj.TrackableType.ToString();
unit = obj.Unit.ToString();
}
// ###########################################################
GUI.backgroundColor = WorldStorageWindow.arfColors[3]; GUI.backgroundColor = WorldStorageWindow.arfColors[3];
if (GUILayout.Button("Delete Trackable")) if (GUILayout.Button("Delete Trackable"))
{ {
Debug.Log("Deleting Trackable"); Debug.Log("Deleting Trackable");
RESTfulTrackableRequest.DeleteTrackable(worldStorageSettings, uid); TrackableRequest.DeleteTrackable(worldStorageServer, UUID);
uid = System.Guid.Empty.ToString(); UUID = System.Guid.Empty.ToString();
creatorUid = System.Guid.Empty.ToString(); creatorUUID = System.Guid.Empty.ToString();
type = ""; type = "";
unit = ""; unit = "";
WorldStorageWindow.WorldStorageWindowSingleton.UpdateList(); WorldStorageWindow.WorldStorageWindowSingleton.UpdateListTrackables();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
GUI.backgroundColor = WorldStorageWindow.arfColors[2]; // ###########################################################
if (GUILayout.Button("Create/Update Trackable"))
{
Debug.Log("PostAddTrackable");
if (string.IsNullOrEmpty(uid) || uid == "0") uid = System.Guid.Empty.ToString();
Trackable t = RESTfulTrackableRequest.TrackableFromStrings(uid, worldStorageSettings.creatorUID);
RESTfulTrackableRequest.PostAddTrackable(worldStorageSettings, t);
WorldStorageWindow.WorldStorageWindowSingleton.UpdateList();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
uid = t.UID.ToString();
type = t.GetType().ToString();
unit = t.UnitSystem.ToString();
}
GUI.backgroundColor = WorldStorageWindow.arfColors[5]; GUI.backgroundColor = WorldStorageWindow.arfColors[5];
if (GUILayout.Button("Generate GameObject Component")) if (GUILayout.Button("Generate GameObject Component"))
{ {
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
} }
static public Trackable GenerateTrackable(string uuid, string name, string creatorUID)
{
EncodingInformationStructure trackableEncodingInformation =
new EncodingInformationStructure(EncodingInformationStructure.DataFormatEnum.ARCORE, "1.0");
Debug.Log("Created encoding information");
#if USING_OPENAPI_GENERATOR
List<double> size = new List<double>();
#else
List<double?> trackableDimension = new List<double?>();
#endif
size.Add(5);
size.Add(5);
Debug.Log("Created dimension");
byte[] bytes = new byte[100];
for (int i = 0; i < bytes.Length; i++)
{
bytes[i] = (byte)i;
}
List<float> crs = new List<float>
{
-2, 1, -3, 4,
4, 4, 4, 2,
1, 0, -2, 1,
-1, -2, 0, 0
};
Dictionary<string, List<string>> kv = new Dictionary<string, List<string>>();
kv.Add("Scenario", new List<string> { "ETSI Trackable" });
System.Guid _uuid = System.Guid.Parse(uuid);
Trackable t = new Trackable(
_uuid,
name,
System.Guid.Parse(creatorUID),
Trackable.TrackableTypeEnum.IMAGEMARKER,
trackableEncodingInformation,
bytes,
crs,
UnitSystem.M,
size,
kv);
t.UUID = _uuid;
return t;
}
} }
} }
\ No newline at end of file
...@@ -4,20 +4,17 @@ ...@@ -4,20 +4,17 @@
// (C) 2022 // (C) 2022
// //
// Development "World Storage", data management, authoring tools // Development "World Storage", data management, authoring tools
// // Date: June 2022
// Authors:
// - Sylvain Renault (Fraunhofer HHI)
//
// Date: Feb. 2022
// //
#define USING_OPENAPI_GENERATOR // alt. is Swagger #define USING_OPENAPI_GENERATOR // alt. is Swagger
//#define isDEBUG
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using ETSI.ARF.WorldStorage.RESTful; using ETSI.ARF.WorldStorage.REST;
#if USING_OPENAPI_GENERATOR #if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
...@@ -31,15 +28,16 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -31,15 +28,16 @@ namespace ETSI.ARF.WorldStorage.UI
{ {
public class WorldAnchorWindow : EditorWindow public class WorldAnchorWindow : EditorWindow
{ {
[HideInInspector] public WorldStorageSettings worldStorageSettings; [HideInInspector] public WorldStorageServer worldStorageServer;
[HideInInspector] public WorldStorageUser worldStorageUser;
[SerializeField] public List<string> anchors = new List<string>(); [SerializeField] public List<string> anchors = new List<string>();
bool groupEnabled; bool groupEnabled;
string creatorUid = System.Guid.Empty.ToString(); string UUID = System.Guid.Empty.ToString();
string uid = System.Guid.Empty.ToString(); string customName = "NotDefined";
string type = "Unknow"; string creatorUUID = System.Guid.Empty.ToString();
string unit = "Unknow"; string unit = "Unknow";
Vector2Int dim; Vector2Int dim;
...@@ -47,10 +45,11 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -47,10 +45,11 @@ namespace ETSI.ARF.WorldStorage.UI
private Color ori; private Color ori;
private GUIStyle gsTest; private GUIStyle gsTest;
public static void ShowWindow(WorldStorageSettings ws) public static void ShowWindow(WorldStorageServer ws, WorldStorageUser user)
{ {
WorldAnchorWindow win = EditorWindow.GetWindow(typeof(WorldAnchorWindow), false, WorldStorageWindow.winName) as WorldAnchorWindow; WorldAnchorWindow win = EditorWindow.GetWindow(typeof(WorldAnchorWindow), false, WorldStorageWindow.winName) as WorldAnchorWindow;
win.worldStorageSettings = ws; win.worldStorageServer = ws;
win.worldStorageUser = user;
} }
public WorldAnchorWindow() public WorldAnchorWindow()
...@@ -67,7 +66,9 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -67,7 +66,9 @@ namespace ETSI.ARF.WorldStorage.UI
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true));
WorldStorageWindow.DrawCopyright(); WorldStorageWindow.DrawCopyright();
DrawAnchorStuffs(); DrawAnchorStuffs();
EditorGUILayout.EndScrollView(); EditorGUILayout.EndScrollView();
if (GUILayout.Button("Close Window")) if (GUILayout.Button("Close Window"))
...@@ -80,25 +81,40 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -80,25 +81,40 @@ namespace ETSI.ARF.WorldStorage.UI
{ {
GUILayout.BeginVertical("AR World Anchor", gsTest); GUILayout.BeginVertical("AR World Anchor", gsTest);
// //
GUILayout.Label("Server: " + worldStorageSettings.serverName, EditorStyles.whiteLargeLabel); GUILayout.Label("Server: " + worldStorageServer.serverName, EditorStyles.whiteLargeLabel);
GUILayout.Label("Creator UID: " + creatorUid, EditorStyles.miniLabel); // readonly GUILayout.Label("User: " + worldStorageUser.userName, EditorStyles.whiteLargeLabel);
EditorGUILayout.Space(); EditorGUILayout.Space();
//GUILayout.BeginHorizontal(); //GUILayout.BeginHorizontal();
uid = EditorGUILayout.TextField("UID (0 = create new)", uid); customName = EditorGUILayout.TextField("Name of Anchor", customName);
#if isDEBUG
GUILayout.Label("UUID: " + UUID, EditorStyles.miniLabel); // readonly
GUILayout.Label("Creator UID: " + creatorUUID, EditorStyles.miniLabel); // readonly
#endif
EditorGUILayout.Space(); EditorGUILayout.Space();
GUI.backgroundColor = WorldStorageWindow.arfColors[1]; GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Get Parameters")) if (GUILayout.Button("Get Parameters"))
{ {
//WorldStorageRestRequest.PostAddTrackable(worldStorageSettings); if (!customName.Contains("[")) UUID = customName;
else
{
// extract the UUID
UUID = customName.Split('[', ']')[1];
}
WorldAnchor obj = WorldAnchorRequest.GetWorldAnchor(worldStorageServer, UUID);
customName = obj.Name;
creatorUUID = obj.CreatorUUID.ToString();
unit = obj.Unit.ToString();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
//GUILayout.EndHorizontal(); //GUILayout.EndHorizontal();
type = EditorGUILayout.TextField("Anchor Type", type);
unit = EditorGUILayout.TextField("Unit System", unit); unit = EditorGUILayout.TextField("Unit System", unit);
EditorGUILayout.Space(10);
dim = EditorGUILayout.Vector2IntField("Dimension", dim);
EditorGUILayout.Space(); EditorGUILayout.Space();
groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled); groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled);
EditorGUILayout.IntField("Number of KeyValues", 0); EditorGUILayout.IntField("Number of KeyValues", 0);
...@@ -106,17 +122,92 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -106,17 +122,92 @@ namespace ETSI.ARF.WorldStorage.UI
EditorGUILayout.TextField("Key", ""); EditorGUILayout.TextField("Key", "");
EditorGUILayout.TextField("Value", ""); EditorGUILayout.TextField("Value", "");
EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndToggleGroup();
// //
GUILayout.EndVertical(); GUILayout.EndVertical();
// ###########################################################
GUI.backgroundColor = WorldStorageWindow.arfColors[2]; GUI.backgroundColor = WorldStorageWindow.arfColors[2];
if (GUILayout.Button("Create/Update World Anchor")) if (GUILayout.Button("Create/Update World Anchor"))
{ {
Debug.Log("PostAddWorldAnchor"); Debug.Log("PostAddWorldAnchor");
RESTfulTrackableRequest.PostAddWorldAnchor(worldStorageSettings);
if (string.IsNullOrEmpty(UUID) || UUID == "0") UUID = System.Guid.Empty.ToString();
WorldAnchor obj = GenerateWorldAnchor(UUID, customName, worldStorageUser.UUID);
WorldAnchorRequest.AddWorldAnchor(worldStorageServer, obj);
WorldStorageWindow.WorldStorageWindowSingleton.UpdateListWorldAnchors();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
UUID = obj.UUID.ToString();
customName = obj.Name;
unit = obj.Unit.ToString();
}
// ###########################################################
GUI.backgroundColor = WorldStorageWindow.arfColors[3];
if (GUILayout.Button("Delete World Anchor"))
{
Debug.Log("Deleting World Anchor");
WorldAnchorRequest.DeleteWorldAnchor(worldStorageServer, UUID);
UUID = System.Guid.Empty.ToString();
creatorUUID = System.Guid.Empty.ToString();
unit = "";
WorldStorageWindow.WorldStorageWindowSingleton.UpdateListWorldAnchors();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
}
GUI.backgroundColor = ori;
// ###########################################################
GUI.backgroundColor = WorldStorageWindow.arfColors[5];
if (GUILayout.Button("Generate GameObject Component"))
{
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
} }
static public WorldAnchor GenerateWorldAnchor(string uuid, string name, string creatorUID)
{
EncodingInformationStructure trackableEncodingInformation =
new EncodingInformationStructure(EncodingInformationStructure.DataFormatEnum.ARCORE, "1.0");
Debug.Log("Created encoding information");
#if USING_OPENAPI_GENERATOR
List<double> size = new List<double>();
#else
List<double?> trackableDimension = new List<double?>();
#endif
size.Add(5);
size.Add(5);
Debug.Log("Created dimension");
byte[] bytes = new byte[100];
for (int i = 0; i < bytes.Length; i++)
{
bytes[i] = (byte)i;
}
List<float> crs = new List<float>
{
-2, 1, -3, 4,
4, 4, 4, 2,
1, 0, -2, 1,
-1, -2, 0, 0
};
Dictionary<string, List<string>> kv = new Dictionary<string, List<string>>();
kv.Add("Scenario", new List<string> { "ETSI WorldAnchor" });
System.Guid _uuid = System.Guid.Parse(uuid);
WorldAnchor t = new WorldAnchor(
_uuid,
name,
System.Guid.Parse(creatorUID),
crs,
UnitSystem.M,
size,
kv);
t.UUID = _uuid;
return t;
}
} }
} }
\ No newline at end of file
...@@ -4,20 +4,18 @@ ...@@ -4,20 +4,18 @@
// (C) 2022 // (C) 2022
// //
// Development "World Storage", data management, authoring tools // Development "World Storage", data management, authoring tools
// // Date: June 2022
// Authors:
// - Sylvain Renault (Fraunhofer HHI)
//
// Date: Feb. 2022
// //
#define USING_OPENAPI_GENERATOR // alt. is Swagger #define USING_OPENAPI_GENERATOR // alt. is Swagger
//#define isDEBUG
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using ETSI.ARF.WorldStorage.RESTful; using ETSI.ARF.WorldStorage;
using ETSI.ARF.WorldStorage.REST;
#if USING_OPENAPI_GENERATOR #if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
...@@ -34,11 +32,15 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -34,11 +32,15 @@ namespace ETSI.ARF.WorldStorage.UI
{ {
static public WorldStorageWindow WorldStorageWindowSingleton; static public WorldStorageWindow WorldStorageWindowSingleton;
[HideInInspector] public WorldStorageSettings worldStorageSettings; [HideInInspector] public WorldStorageServer worldStorageServer;
[HideInInspector] public WorldStorageUser worldStorageUser;
[SerializeField] public List<string> creators = new List<string>(); [SerializeField] public List<string> creators = new List<string>();
[SerializeField] public List<string> trackables = new List<string>(); [SerializeField] public List<string> trackables = new List<string>();
[SerializeField] public List<string> anchors = new List<string>();
string ping = "-";
string state = "Unknow";
string vers = "Unknow"; string vers = "Unknow";
private Vector2 scrollPos; private Vector2 scrollPos;
...@@ -67,6 +69,7 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -67,6 +69,7 @@ namespace ETSI.ARF.WorldStorage.UI
{ {
WorldStorageWindowSingleton = this; WorldStorageWindowSingleton = this;
} }
static public void DrawCopyright() static public void DrawCopyright()
{ {
// Title // Title
...@@ -89,12 +92,12 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -89,12 +92,12 @@ namespace ETSI.ARF.WorldStorage.UI
if (GUILayout.Button("Create/Edit Trackable...")) if (GUILayout.Button("Create/Edit Trackable..."))
{ {
Debug.Log("Open Trackable Window"); Debug.Log("Open Trackable Window");
TrackableWindow.ShowWindow(worldStorageSettings); TrackableWindow.ShowWindow(worldStorageServer, worldStorageUser);
} }
if (GUILayout.Button("Create/Edit World Anchor...")) if (GUILayout.Button("Create/Edit World Anchor..."))
{ {
Debug.Log("Open World Anchor Window"); Debug.Log("Open World Anchor Window");
WorldAnchorWindow.ShowWindow(worldStorageSettings); WorldAnchorWindow.ShowWindow(worldStorageServer, worldStorageUser);
} }
if (GUILayout.Button("Create/Edit Link...")) if (GUILayout.Button("Create/Edit Link..."))
{ {
...@@ -108,15 +111,29 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -108,15 +111,29 @@ namespace ETSI.ARF.WorldStorage.UI
EditorGUILayout.EndScrollView(); EditorGUILayout.EndScrollView();
} }
public void UpdateList() public void UpdateListTrackables()
{ {
// Get all objects // Get all objects
Debug.Log("Get all server objects"); Debug.Log("Get all server objects");
List<Trackable> res = RESTfulTrackableRequest.GetAllTrackables(worldStorageSettings); List<Trackable> res = TrackableRequest.GetAllTrackables(worldStorageServer);
trackables.Clear(); trackables.Clear();
foreach (var item in res) foreach (var item in res)
{ {
trackables.Add(item.UID.ToString()); if (!string.IsNullOrEmpty(item.Name)) trackables.Add(item.Name + " [" + item.UUID.ToString() + "]");
else trackables.Add(item.UUID.ToString());
}
}
public void UpdateListWorldAnchors()
{
// Get all objects
Debug.Log("Get all server objects");
List<WorldAnchor> res = WorldAnchorRequest.GetAllWorldAnchors(worldStorageServer);
anchors.Clear();
foreach (var item in res)
{
if (!string.IsNullOrEmpty(item.Name)) anchors.Add(item.Name + " [" + item.UUID.ToString() + "]");
else anchors.Add(item.UUID.ToString());
} }
} }
...@@ -126,48 +143,68 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -126,48 +143,68 @@ namespace ETSI.ARF.WorldStorage.UI
GUILayout.BeginVertical("World Storage Server", gsTest); GUILayout.BeginVertical("World Storage Server", gsTest);
// //
GUILayout gl = new GUILayout(); GUILayout gl = new GUILayout();
GUILayout.Label("Server Name: " + worldStorageSettings.serverName, EditorStyles.whiteLargeLabel);
GUILayout.Label("Own Creator UID: " + worldStorageSettings.creatorUID);
GUILayout.Label("Base Path: " + worldStorageSettings.basePath);
GUILayout.Label("Port: " + worldStorageSettings.port);
EditorGUILayout.Space(); GUILayout.Label("Server Name: " + worldStorageServer.serverName, EditorStyles.whiteLargeLabel);
GUILayout.Label("User Name: " + worldStorageUser.userName, EditorStyles.whiteLargeLabel);
#if isDEBUG
GUILayout.Label("Creator UID: " + worldStorageUser.UUID);
GUILayout.Label("Base Path: " + worldStorageServer.basePath);
GUILayout.Label("Port: " + worldStorageServer.port);
#endif
// Ping
EditorGUILayout.Space(); EditorGUILayout.Space();
#region Ping
GUILayout.BeginHorizontal();
ping = EditorGUILayout.TextField("Last Ping", ping);
if (GUILayout.Button("Ping")) if (GUILayout.Button("Ping"))
{ {
vers = RESTfulTrackableRequest.Ping(worldStorageSettings); ping = AdminRequest.Ping(worldStorageServer);
} }
GUI.backgroundColor = ori;
GUILayout.EndHorizontal();
#endregion
#region State
GUILayout.BeginHorizontal();
state = EditorGUILayout.TextField("State", state);
if (GUILayout.Button("Get World Storage Sate"))
{
state = AdminRequest.GetAdminInfo(worldStorageServer);
}
GUI.backgroundColor = ori;
GUILayout.EndHorizontal();
#endregion
// Version #region Version
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
vers = EditorGUILayout.TextField("Version", vers); vers = EditorGUILayout.TextField("Version", vers);
if (GUILayout.Button("Get World Storage API Version")) if (GUILayout.Button("Get World Storage API Version"))
{ {
vers = RESTfulTrackableRequest.GetAdminInfo(worldStorageSettings); vers = AdminRequest.GetVersion(worldStorageServer);
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
#endregion
ScriptableObject target = this; ScriptableObject target = this;
SerializedObject so = new SerializedObject(target); SerializedObject so = new SerializedObject(target);
// Get creators // Get creators
#region Get all creatorUid #region Get all creator UUID
EditorGUILayout.Space(10); EditorGUILayout.Space(10);
GUI.backgroundColor = WorldStorageWindow.arfColors[1]; GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Request all Creator ID")) if (GUILayout.Button("Request all Creator ID"))
{ {
// Get all objects // Get all objects
Debug.Log("Get all creators id"); Debug.Log("Get all creators id");
List<Trackable> res = RESTfulTrackableRequest.GetAllTrackables(worldStorageSettings); List<Trackable> res = TrackableRequest.GetAllTrackables(worldStorageServer);
creators.Clear(); creators.Clear();
foreach (var item in res) foreach (var item in res)
{ {
if (!creators.Contains(item.CreatorUID.ToString())) creators.Add(item.CreatorUID.ToString()); if (!creators.Contains(item.CreatorUUID.ToString())) creators.Add(item.CreatorUUID.ToString());
} }
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
...@@ -175,58 +212,91 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -175,58 +212,91 @@ namespace ETSI.ARF.WorldStorage.UI
SerializedProperty stringsProperty = so.FindProperty("creators"); SerializedProperty stringsProperty = so.FindProperty("creators");
EditorGUILayout.PropertyField(stringsProperty, true); // True means show children EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
so.ApplyModifiedProperties(); // Remember to apply modified properties so.ApplyModifiedProperties(); // Remember to apply modified properties
#endregion #endregion
//
// Get trackables // Get trackables
#region Get all trackable objects //
#region Get all trackable objects
EditorGUILayout.Space(10); EditorGUILayout.Space(10);
// ###########################################################
GUI.backgroundColor = WorldStorageWindow.arfColors[1]; GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Request all Trackable ID")) if (GUILayout.Button("Request Trackables"))
{ {
UpdateList(); UpdateListTrackables();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
//GUILayout.Label("Number of Trackables: " + trackables.Count.ToString());
// ###########################################################
GUI.backgroundColor = WorldStorageWindow.arfColors[3]; GUI.backgroundColor = WorldStorageWindow.arfColors[3];
if (GUILayout.Button("Delete all Trackables (5 stay in!!!)")) if (GUILayout.Button("Delete all Trackables (3 stay in!!!)"))
{ {
Debug.Log("Deleting all Trackable "); Debug.Log("Deleting all Trackable ");
int n = 0; int n = 0;
foreach (var item in trackables) foreach (var item in trackables)
{ {
if (++n > 5) RESTfulTrackableRequest.DeleteTrackable(worldStorageSettings, item); if (++n > 3) TrackableRequest.DeleteTrackable(worldStorageServer, item);
} }
UpdateList(); UpdateListTrackables();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
// Show list
stringsProperty = so.FindProperty("trackables"); stringsProperty = so.FindProperty("trackables");
EditorGUILayout.PropertyField(stringsProperty, /*new GUIContent("Trackbales"),*/ true); // True means show children EditorGUILayout.PropertyField(stringsProperty, /*new GUIContent("Trackbales"),*/ true); // True means show children
so.ApplyModifiedProperties(); // Remember to apply modified properties so.ApplyModifiedProperties(); // Remember to apply modified properties
#endregion #endregion
//
// Get anchors
//
#region Get all anchor objects
EditorGUILayout.Space(10);
// Anchors // ###########################################################
#region Get all anchor objects
GUI.backgroundColor = WorldStorageWindow.arfColors[1]; GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Request all Anchor ID")) if (GUILayout.Button("Request World Anchors"))
{ {
UpdateListWorldAnchors();
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
#endregion
// Links // ###########################################################
#region Get all link objects GUI.backgroundColor = WorldStorageWindow.arfColors[3];
if (GUILayout.Button("Delete all World Anchors (3 stay in!!!)"))
{
Debug.Log("Deleting all World Anchors ");
int n = 0;
foreach (var item in anchors)
{
if (++n > 3) WorldAnchorRequest.DeleteWorldAnchor(worldStorageServer, item);
}
UpdateListWorldAnchors();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
}
GUI.backgroundColor = ori;
// Show list
stringsProperty = so.FindProperty("anchors");
EditorGUILayout.PropertyField(stringsProperty, /*new GUIContent("Trackbales"),*/ true); // True means show children
so.ApplyModifiedProperties(); // Remember to apply modified properties
#endregion
//
// Get Links
//
#region Get all link objects
GUI.backgroundColor = WorldStorageWindow.arfColors[1]; GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Request all Link ID")) if (GUILayout.Button("Request World Links"))
{ {
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
#endregion #endregion
// //
GUILayout.EndVertical(); GUILayout.EndVertical();
......
...@@ -18,15 +18,15 @@ using UnityEditor; ...@@ -18,15 +18,15 @@ using UnityEditor;
namespace ETSI.ARF.WorldStorage.UI namespace ETSI.ARF.WorldStorage.UI
{ {
[CustomEditor(typeof(WorldStorageSettings))] [CustomEditor(typeof(WorldStorageServer))]
public class WorldStorageSettingsEditor : Editor public class WorldStorageServerEditor : Editor
{ {
WorldStorageSettings worldStorageSettings; WorldStorageServer worldStorageServer;
WorldStorageWindow win; WorldStorageWindow win;
public void OnEnable() public void OnEnable()
{ {
worldStorageSettings = (WorldStorageSettings)target; worldStorageServer = (WorldStorageServer)target;
} }
public override void OnInspectorGUI() public override void OnInspectorGUI()
...@@ -41,24 +41,14 @@ namespace ETSI.ARF.WorldStorage.UI ...@@ -41,24 +41,14 @@ namespace ETSI.ARF.WorldStorage.UI
DrawDefaultInspector(); DrawDefaultInspector();
EditorGUILayout.Space(); EditorGUILayout.Space();
// creator uid button // open window button
//GUILayout.BeginHorizontal();
//GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Create New Creator UID"))
{
worldStorageSettings.creatorUID = System.Guid.NewGuid().ToString();
if (win != null) win.worldStorageSettings.creatorUID = worldStorageSettings.creatorUID;
}
//GUI.backgroundColor = ori;
//GUILayout.EndHorizontal();
// open win button
GUI.backgroundColor = WorldStorageWindow.arfColors[1]; GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Open World Storage Window...")) if (GUILayout.Button("Open World Storage Window..."))
{ {
Debug.Log("Open Main ARF Window"); Debug.Log("Open Main ARF Window");
win = EditorWindow.GetWindow(typeof(WorldStorageWindow), false, "ETSI ARF - Authoring Editor") as WorldStorageWindow; win = EditorWindow.GetWindow(typeof(WorldStorageWindow), false, "ETSI ARF - Authoring Editor") as WorldStorageWindow;
win.worldStorageSettings = worldStorageSettings; win.worldStorageServer = worldStorageServer;
win.worldStorageUser = worldStorageServer.user;
} }
GUI.backgroundColor = ori; GUI.backgroundColor = ori;
} }
......
//
// ETSI (European Telecommunications Standards Institute, referred to as ETSI)
// ARF - ETSI ISG Augmented Reality Framework (ISG ARF)
// (C) 2022
//
// Development "World Storage", data management, authoring tools
//
// Authors:
// - Sylvain Renault (Fraunhofer HHI)
//
// Date: Feb. 2022
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace ETSI.ARF.WorldStorage.UI
{
[CustomEditor(typeof(WorldStorageUser))]
public class WorldStorageUserEditor : Editor
{
WorldStorageUser worldStorageUser;
WorldStorageWindow win;
public void OnEnable()
{
worldStorageUser = (WorldStorageUser)target;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
Color ori = GUI.backgroundColor;
GUILayout.Label("Copyright(c) 2022, ETSI - ARF");
EditorGUILayout.Space();
GUILayout.Label("Parameters:", EditorStyles.boldLabel);
DrawDefaultInspector();
EditorGUILayout.Space();
// creator UUID button
GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Generate New Creator UUID"))
{
worldStorageUser.UUID = System.Guid.NewGuid().ToString();
if (win != null) win.worldStorageUser.UUID = worldStorageUser.UUID;
}
GUI.backgroundColor = ori;
}
}
}
\ No newline at end of file
fileFormatVersion: 2 fileFormatVersion: 2
guid: 963ad0211af9f3f48a53e88d9f9f5be5 guid: 134a71a4b493ae1468ea8de88c99135c
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
...@@ -10,9 +10,9 @@ MonoBehaviour: ...@@ -10,9 +10,9 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e4b7be4c33f68d0418c3b4e1a7053d91, type: 3} m_Script: {fileID: 11500000, guid: e4b7be4c33f68d0418c3b4e1a7053d91, type: 3}
m_Name: WorldStorageSettings_HHI_Detlef m_Name: HHI Server - local
m_EditorClassIdentifier: m_EditorClassIdentifier:
serverName: Detlef's PC serverName: HHI Server (Detlef)
creatorUID: 00000000-0000-0000-0000-000000000000
basePath: http://172.17.132.19 basePath: http://172.17.132.19
port: 8080 port: 8080
user: {fileID: 11400000, guid: ce0f40be06008b14283766424922b729, type: 2}
fileFormatVersion: 2 fileFormatVersion: 2
guid: b656b4f6c38b83148a06d0ccd523227c guid: 62e22250d4134d64ca319770717f0b43
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000
......
...@@ -10,8 +10,9 @@ MonoBehaviour: ...@@ -10,8 +10,9 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e4b7be4c33f68d0418c3b4e1a7053d91, type: 3} m_Script: {fileID: 11500000, guid: e4b7be4c33f68d0418c3b4e1a7053d91, type: 3}
m_Name: myWorldStorageSettings m_Name: HHI Server
m_EditorClassIdentifier: m_EditorClassIdentifier:
serverName: HHI Servers serverName: HHI World Storage Server
basePath: https://localhosts basePath: https://ics1.hhi.fraunhofer.de/
port: 40311 port: 8080
user: {fileID: 11400000, guid: ce0f40be06008b14283766424922b729, type: 2}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 1d9997341aa0c1c45810f4b291addf39 guid: 4f997253243de534dad12937f1284975
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000
......
%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: Sylvain
m_EditorClassIdentifier:
userName: Sylvain R.
UUID: faee4241-62ac-47d1-92c8-5b4b7a5fbc93
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