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

First version.

parent d354935f
No related branches found
No related tags found
No related merge requests found
Showing
with 1301 additions and 0 deletions
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/
# Fraunhofer HHI / IMC / Unity settings
#/[Aa]ssets/Fraunhofer
/[Aa]pp
/[Bb]in
/[Ee]xe
# Never ignore Asset meta data
!/[Aa]ssets/**/*.meta
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# TextMesh Pro files
#[Aa]ssets/TextMesh*Pro/
# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties
\ No newline at end of file
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
fileFormatVersion: 2
guid: db2f797f7c52e3747afa150badb0577f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e4474d3a0bcb9c44d9fd67da1ebb77c9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5fec767e3d1954e4e8af5dc2b3d4dd5d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 452c5e5fd6387ad4984356aa2f11d245
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.Experimental.GraphView;
using System;
namespace ETSI.ARF.WorldStorage.UI
{
public class ARFGraphView : GraphView
{
public ARFGraphView()
{
//GridBackground back = new GridBackground();
//back.StretchToParentSize();
//Insert(0, back);
this.AddManipulator(new ContentDragger());
this.AddManipulator(new SelectionDragger());
this.AddManipulator(new RectangleSelector());
AddElement(GenerateEntryPointNode());
}
public override List<Port> GetCompatiblePorts(Port startPort, NodeAdapter nodeAdapter)
{
var cPorts = new List<Port>();
ports.ForEach (funcCall: port =>
{
if (startPort != port && startPort.node != port.node) cPorts.Add(port);
});
return cPorts;
}
private Port GeneratePort (ARFNode node, Direction portDirection, Port.Capacity capacity = Port.Capacity.Multi)
{
return node.InstantiatePort(Orientation.Horizontal, portDirection, capacity, typeof(int)); // dummy
}
private ARFNode GenerateEntryPointNode()
{
var node = new ARFNode
{
title = "World Storage",
text = "EntryPoint",
GUID = Guid.NewGuid().ToString(),
entryPoint = true
};
var portOut = GeneratePort(node, Direction.Output);
portOut.portName = "Link";
node.outputContainer.Add(portOut);
node.RefreshExpandedState();
node.RefreshPorts();
node.SetPosition(new Rect(50, 100, 200, 150));
return node;
}
public void CreateNode(string name)
{
AddElement(CreateARFNode(name));
}
public ARFNode CreateARFNode(string name)
{
var node = new ARFNode
{
title = name,
text = name,
GUID = Guid.NewGuid().ToString()
};
var portIn = GeneratePort(node, Direction.Input, Port.Capacity.Multi);
portIn.portName = "Link"; // "Input";
node.inputContainer.Add(portIn);
var portOut = GeneratePort(node, Direction.Output, Port.Capacity.Multi);
portOut.portName = "Link"; // "Output";
node.outputContainer.Add(portOut);
node.RefreshExpandedState();
node.RefreshPorts();
node.SetPosition(new Rect(200, 100, 200, 150));
return node;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 000c7511b9bdea24cb6c962ca1ae26ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//
// 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 UnityEngine.UIElements;
using UnityEditor.Experimental.GraphView;
namespace ETSI.ARF.WorldStorage.UI
{
public class ARFNode : Node
{
public string GUID;
public string text;
public bool entryPoint = false;
public ARFNode()
{
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 0216cf1af3743f2429eb4b01db300b0e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
// 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
guid: 963ad0211af9f3f48a53e88d9f9f5be5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#define USING_OPENAPI_GENERATOR // alt. is Swagger
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
using ETSI.ARF.WorldStorage.RESTful;
#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
using IO.Swagger.Model;
#endif
namespace ETSI.ARF.WorldStorage.UI
{
public class GraphWindow : EditorWindow
{
[HideInInspector] public WorldStorageSettings worldStorageSettings;
[SerializeField] public List<string> trackables = new List<string>();
bool groupEnabled;
string uid = System.Guid.Empty.ToString();
string creatorUid = System.Guid.Empty.ToString();
string type = "Unknow";
string unit = "Unknow";
Vector2Int dim;
private Trackable currentTrackable;
private Vector2 scrollPos;
private Color ori;
private GUIStyle gsTest;
private ARFGraphView myGraph;
[MenuItem("[ ISG-ARF ]/Graph Editor")]
public static void ShowWindow()//WorldStorageSettings ws)
{
GraphWindow win = EditorWindow.GetWindow(typeof(GraphWindow), false, WorldStorageWindow.winName) as GraphWindow;
//win.worldStorageSettings = ws;
}
public GraphWindow()
{
// init somne stuffs
//currentTrackable = new Trackable();
}
public void OnEnable()
{
ConstructGraphView();
GenerateToolbar();
}
public void OnDisable()
{
rootVisualElement.Remove(myGraph);
}
private void GenerateToolbar()
{
var toolbar = new Toolbar();
var createNodeT = new Button(clickEvent: () => { myGraph.CreateNode("Trackable"); });
createNodeT.text = "Create Trackable";
toolbar.Add(createNodeT);
var createNodeWA = new Button(clickEvent: () => { myGraph.CreateNode("World Anchor"); });
createNodeWA.text = "Create World Anchor";
toolbar.Add(createNodeWA);
var createNodeL = new Button(clickEvent: () => { });
createNodeL.text = "Create Link";
toolbar.Add(createNodeL);
var close = new Button(clickEvent: () => { Close(); });
close.text = "Close Window";
toolbar.Add(close);
rootVisualElement.Add(toolbar);
}
private void ConstructGraphView()
{
myGraph = new ARFGraphView
{
name = "ARF Graph"
};
myGraph.StretchToParentSize();
//myGraph.StretchToParentWidth();
rootVisualElement.Add(myGraph);
}
void OnGUI()
{
ori = GUI.backgroundColor; // remember ori color
gsTest = new GUIStyle("window");
gsTest.normal.textColor = WorldStorageWindow.arfColors[0];
gsTest.fontStyle = FontStyle.Bold;
EditorGUILayout.Space(24);
GUI.contentColor = WorldStorageWindow.arfColors[1];
WorldStorageWindow.DrawCopyright();
//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();
}
void DrawTrackableStuffs()// Trackable trackable)
{
GUILayout.BeginVertical("AR Trackable", gsTest);
//
GUILayout.Label("Server: " + worldStorageSettings.serverName, EditorStyles.whiteLargeLabel);
GUILayout.Label("Creator UID: " + creatorUid, EditorStyles.miniLabel); // readonly
EditorGUILayout.Space();
//GUILayout.BeginHorizontal();
uid = EditorGUILayout.TextField("UID (0 = new one)", uid);
EditorGUILayout.Space();
GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Get Parameters"))
{
Trackable t = RESTfulTrackableRequest.GetTrackable(worldStorageSettings, uid);
creatorUid = t.CreatorUID.ToString();
type = t.GetType().ToString();
unit = t.UnitSystem.ToString();
}
GUI.backgroundColor = ori;
type = EditorGUILayout.TextField("Trackable Type", type);
unit = EditorGUILayout.TextField("Unit System", unit);
EditorGUILayout.Space(10);
dim = EditorGUILayout.Vector2IntField("Dimension", dim);
EditorGUILayout.Space();
GUILayout.Button("Payload from Asset...");
EditorGUILayout.Space();
groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled);
EditorGUILayout.IntField("Number of KeyValues", 0);
EditorGUILayout.Space();
EditorGUILayout.TextField("Key", "");
EditorGUILayout.TextField("Value", "");
EditorGUILayout.EndToggleGroup();
//
GUILayout.EndVertical();
GUI.backgroundColor = WorldStorageWindow.arfColors[3];
if (GUILayout.Button("Delete Trackable"))
{
Debug.Log("Deleting Trackable");
RESTfulTrackableRequest.DeleteTrackable(worldStorageSettings, uid);
uid = System.Guid.Empty.ToString();
creatorUid = System.Guid.Empty.ToString();
type = "";
unit = "";
WorldStorageWindow.WorldStorageWindowSingleton.UpdateList();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
}
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 = ori;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 8dd64e8d8a545ab45b424402550b55a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//
// 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
//
#define USING_OPENAPI_GENERATOR // alt. is Swagger
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ETSI.ARF.WorldStorage.RESTful;
#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
using IO.Swagger.Model;
#endif
namespace ETSI.ARF.WorldStorage.UI
{
public class TrackableWindow : EditorWindow
{
[HideInInspector] public WorldStorageSettings worldStorageSettings;
[SerializeField] public List<string> trackables = new List<string>();
bool groupEnabled;
string uid = System.Guid.Empty.ToString();
string creatorUid = System.Guid.Empty.ToString();
string type = "Unknow";
string unit = "Unknow";
Vector2Int dim;
private Trackable currentTrackable;
private Vector2 scrollPos;
private Color ori;
private GUIStyle gsTest;
public static void ShowWindow(WorldStorageSettings ws)
{
TrackableWindow win = EditorWindow.GetWindow(typeof(TrackableWindow), false, WorldStorageWindow.winName) as TrackableWindow;
win.worldStorageSettings = ws;
}
public TrackableWindow()
{
// init somne stuffs
//currentTrackable = new Trackable();
}
void OnGUI()
{
ori = GUI.backgroundColor; // remember ori color
gsTest = new GUIStyle("window");
gsTest.normal.textColor = WorldStorageWindow.arfColors[0];
gsTest.fontStyle = FontStyle.Bold;
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true));
WorldStorageWindow.DrawCopyright();
DrawTrackableStuffs();// currentTrackable);
EditorGUILayout.EndScrollView();
if (GUILayout.Button("Close Window"))
{
Close();
}
}
void DrawTrackableStuffs()// Trackable trackable)
{
GUILayout.BeginVertical("AR Trackable", gsTest);
//
GUILayout.Label("Server: " + worldStorageSettings.serverName, EditorStyles.whiteLargeLabel);
GUILayout.Label("Creator UID: " + creatorUid, EditorStyles.miniLabel); // readonly
EditorGUILayout.Space();
//GUILayout.BeginHorizontal();
uid = EditorGUILayout.TextField("UID (0 = new one)", uid);
EditorGUILayout.Space();
GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Get Parameters"))
{
Trackable t = RESTfulTrackableRequest.GetTrackable(worldStorageSettings, uid);
creatorUid = t.CreatorUID.ToString();
type = t.GetType().ToString();
unit = t.UnitSystem.ToString();
}
GUI.backgroundColor = ori;
type = EditorGUILayout.TextField("Trackable Type", type);
unit = EditorGUILayout.TextField("Unit System", unit);
EditorGUILayout.Space(10);
dim = EditorGUILayout.Vector2IntField("Dimension", dim);
EditorGUILayout.Space();
GUILayout.Button("Payload from Asset...");
EditorGUILayout.Space();
groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled);
EditorGUILayout.IntField("Number of KeyValues", 0);
EditorGUILayout.Space();
EditorGUILayout.TextField("Key", "");
EditorGUILayout.TextField("Value", "");
EditorGUILayout.EndToggleGroup();
//
GUILayout.EndVertical();
GUI.backgroundColor = WorldStorageWindow.arfColors[3];
if (GUILayout.Button("Delete Trackable"))
{
Debug.Log("Deleting Trackable");
RESTfulTrackableRequest.DeleteTrackable(worldStorageSettings, uid);
uid = System.Guid.Empty.ToString();
creatorUid = System.Guid.Empty.ToString();
type = "";
unit = "";
WorldStorageWindow.WorldStorageWindowSingleton.UpdateList();
WorldStorageWindow.WorldStorageWindowSingleton.Repaint();
}
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];
if (GUILayout.Button("Generate GameObject Component"))
{
}
GUI.backgroundColor = ori;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 229d5ea484d30f945b9318581fb4f2da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//
// 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
//
#define USING_OPENAPI_GENERATOR // alt. is Swagger
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ETSI.ARF.WorldStorage.RESTful;
#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
using IO.Swagger.Model;
#endif
namespace ETSI.ARF.WorldStorage.UI
{
public class WorldAnchorWindow : EditorWindow
{
[HideInInspector] public WorldStorageSettings worldStorageSettings;
[SerializeField] public List<string> anchors = new List<string>();
bool groupEnabled;
string creatorUid = System.Guid.Empty.ToString();
string uid = System.Guid.Empty.ToString();
string type = "Unknow";
string unit = "Unknow";
Vector2Int dim;
private Vector2 scrollPos;
private Color ori;
private GUIStyle gsTest;
public static void ShowWindow(WorldStorageSettings ws)
{
WorldAnchorWindow win = EditorWindow.GetWindow(typeof(WorldAnchorWindow), false, WorldStorageWindow.winName) as WorldAnchorWindow;
win.worldStorageSettings = ws;
}
public WorldAnchorWindow()
{
// init somne stuffs
}
void OnGUI()
{
ori = GUI.backgroundColor; // remember ori color
gsTest = new GUIStyle("window");
gsTest.normal.textColor = WorldStorageWindow.arfColors[0];
gsTest.fontStyle = FontStyle.Bold;
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true));
WorldStorageWindow.DrawCopyright();
DrawAnchorStuffs();
EditorGUILayout.EndScrollView();
if (GUILayout.Button("Close Window"))
{
Close();
}
}
void DrawAnchorStuffs()
{
GUILayout.BeginVertical("AR World Anchor", gsTest);
//
GUILayout.Label("Server: " + worldStorageSettings.serverName, EditorStyles.whiteLargeLabel);
GUILayout.Label("Creator UID: " + creatorUid, EditorStyles.miniLabel); // readonly
EditorGUILayout.Space();
//GUILayout.BeginHorizontal();
uid = EditorGUILayout.TextField("UID (0 = create new)", uid);
EditorGUILayout.Space();
GUI.backgroundColor = WorldStorageWindow.arfColors[1];
if (GUILayout.Button("Get Parameters"))
{
//WorldStorageRestRequest.PostAddTrackable(worldStorageSettings);
}
GUI.backgroundColor = ori;
//GUILayout.EndHorizontal();
type = EditorGUILayout.TextField("Anchor Type", type);
unit = EditorGUILayout.TextField("Unit System", unit);
EditorGUILayout.Space();
groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled);
EditorGUILayout.IntField("Number of KeyValues", 0);
EditorGUILayout.Space();
EditorGUILayout.TextField("Key", "");
EditorGUILayout.TextField("Value", "");
EditorGUILayout.EndToggleGroup();
//
GUILayout.EndVertical();
GUI.backgroundColor = WorldStorageWindow.arfColors[2];
if (GUILayout.Button("Create/Update World Anchor"))
{
Debug.Log("PostAddWorldAnchor");
RESTfulTrackableRequest.PostAddWorldAnchor(worldStorageSettings);
}
GUI.backgroundColor = ori;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: a0f67f823dd6ff246be6c656b120756e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//
// 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(WorldStorageSettings))]
public class WorldStorageSettingsEditor : Editor
{
WorldStorageSettings worldStorageSettings;
WorldStorageWindow win;
public void OnEnable()
{
worldStorageSettings = (WorldStorageSettings)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 uid 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];
if (GUILayout.Button("Open World Storage Window..."))
{
Debug.Log("Open Main ARF Window");
win = EditorWindow.GetWindow(typeof(WorldStorageWindow), false, "ETSI ARF - Authoring Editor") as WorldStorageWindow;
win.worldStorageSettings = worldStorageSettings;
}
GUI.backgroundColor = ori;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 878ee3c4c6608354f90354fd159f4e04
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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