Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Delayed input fields for CesiumGeoreference editor #399

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading