Skip to content

Commit

Permalink
Use Delayed input fields for georeference editor
Browse files Browse the repository at this point in the history
  • Loading branch information
azrogers committed Jan 30, 2024
1 parent 99c6a02 commit cbbdc38
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Editor/CesiumGeoreferenceEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ private void DrawLongitudeLatitudeHeightProperties()
this._latitude,
-90.0,
90.0,
latitudeContent);
latitudeContent,
delayed: true);

GUIContent longitudeContent = new GUIContent(
"Longitude",
Expand All @@ -149,7 +150,8 @@ private void DrawLongitudeLatitudeHeightProperties()
this._longitude,
-180.0,
180.0,
longitudeContent);
longitudeContent,
delayed: true);

GUIContent heightContent = new GUIContent(
"Height",
Expand Down
13 changes: 10 additions & 3 deletions Editor/CesiumInspectorGUI.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

using System;
using System.Text.RegularExpressions;
using Unity.Mathematics;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -139,13 +138,21 @@ public static void ClampedFloatField(
}

public static void ClampedDoubleField(
SerializedProperty property, double min, double max, GUIContent label)
SerializedProperty property, double min, double max, GUIContent label, bool delayed = false)
{
// SerializedPropertyType.Float is used for both float and double;
// SerializedPropertyType.Double does not exist.
if (property.propertyType == SerializedPropertyType.Float)
{
double value = EditorGUILayout.DoubleField(label, property.doubleValue);
double value;
if (delayed)
{
value = EditorGUILayout.DelayedDoubleField(label, property.doubleValue);
}
else
{
value = EditorGUILayout.DoubleField(label, property.doubleValue);
}
property.doubleValue = Math.Clamp(value, min, max);
}
else
Expand Down
6 changes: 5 additions & 1 deletion Runtime/CesiumGeoreference.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Reinterop;
using System;
using System.Collections.Generic;
using Reinterop;
using Unity.Mathematics;
using UnityEngine;

Expand Down Expand Up @@ -76,15 +76,19 @@ public partial class CesiumGeoreference : MonoBehaviour
private double _longitude = -105.25737;

[SerializeField]
[Delayed]
private double _height = 2250.0;

[SerializeField]
[Delayed]
private double _ecefX = 6378137.0;

[SerializeField]
[Delayed]
private double _ecefY = 0.0;

[SerializeField]
[Delayed]
private double _ecefZ = 0.0;

[SerializeField]
Expand Down

0 comments on commit cbbdc38

Please sign in to comment.