CircleProximityFieldEditor.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using UnityEditor;
  2. using UnityEngine;
  3. using Rokid.UXR.Interaction;
  4. namespace Rokid.UXR.Editor
  5. {
  6. [CustomEditor(typeof(CircleProximityField))]
  7. public class CircleProximityFieldEditor : UnityEditor.Editor
  8. {
  9. private SerializedProperty _transformProperty;
  10. private SerializedProperty _radiusProperty;
  11. private void Awake()
  12. {
  13. _transformProperty = serializedObject.FindProperty("_transform");
  14. _radiusProperty = serializedObject.FindProperty("_radius");
  15. }
  16. public void OnSceneGUI()
  17. {
  18. Handles.color = EditorConstants.PRIMARY_COLOR;
  19. Transform transform = _transformProperty.objectReferenceValue as Transform;
  20. float radius = _radiusProperty.floatValue * transform.lossyScale.x;
  21. #if UNITY_2020_2_OR_NEWER
  22. Handles.DrawWireDisc(transform.position, -transform.forward, radius, EditorConstants.LINE_THICKNESS);
  23. #else
  24. Handles.DrawWireDisc(transform.position, -transform.forward, radius);
  25. #endif
  26. }
  27. }
  28. }