GPSPinPropertyDrawer.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // using System.Collections;
  2. // using System.Collections.Generic;
  3. // using UnityEngine;
  4. // using UnityEditor;
  5. // namespace Imagine.WebAR.Editor{
  6. // [CustomPropertyDrawer(typeof(GPSPin))]
  7. // public class GPSPinPropertyDrawer : PropertyDrawer
  8. // {
  9. // public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  10. // {
  11. // EditorGUI.BeginProperty(position, label, property);
  12. // // Indent label and content
  13. // //position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
  14. // // Calculate rects
  15. // var nameRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
  16. // var transformRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width, EditorGUIUtility.singleLineHeight);
  17. // var latitudeRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight * 3, position.width, EditorGUIUtility.singleLineHeight);
  18. // var longitudeRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight * 4, position.width, EditorGUIUtility.singleLineHeight);
  19. // var altitudeRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight * 5, position.width, EditorGUIUtility.singleLineHeight);
  20. // var buttonRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight * 6, position.width, EditorGUIUtility.singleLineHeight);
  21. // // Find the properties
  22. // SerializedProperty nameProp = property.FindPropertyRelative("name");
  23. // SerializedProperty transformProp = property.FindPropertyRelative("transform");
  24. // SerializedProperty latitudeProp = property.FindPropertyRelative("latitude");
  25. // SerializedProperty longitudeProp = property.FindPropertyRelative("longitude");
  26. // SerializedProperty altitudeProp = property.FindPropertyRelative("altitude");
  27. // // Draw fields
  28. // EditorGUI.PropertyField(nameRect, nameProp);
  29. // EditorGUI.PropertyField(transformRect, transformProp);
  30. // EditorGUI.PropertyField(latitudeRect, latitudeProp);
  31. // EditorGUI.PropertyField(longitudeRect, longitudeProp);
  32. // EditorGUI.PropertyField(altitudeRect, altitudeProp);
  33. // if(GUI.Button(buttonRect, "View in Google Maps")){
  34. // var latitude = property.FindPropertyRelative("latitude").floatValue;
  35. // var longitude = property.FindPropertyRelative("longitude").floatValue;
  36. // Application.OpenURL($"https://www.google.com/maps/place/{latitude},{longitude}/@{latitude},{longitude},60m/data=!3m1!1e3?entry=ttu");
  37. // }
  38. // EditorGUI.EndProperty();
  39. // }
  40. // public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  41. // {
  42. // // Height of the property drawer
  43. // return EditorGUIUtility.singleLineHeight * 8;
  44. // }
  45. // }
  46. // }