// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System.Collections.Generic; using UltimateXR.Manipulation; using UnityEditor; using UnityEngine; namespace UltimateXR.Editor.Manipulation { /// /// Custom property drawer for the class. /// [CustomPropertyDrawer(typeof(UxrGrabPointIndex))] public class UxrGrabPointIndexDrawer : PropertyDrawer { #region Public Overrides PropertyDrawer /// public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { return EditorGUIUtility.singleLineHeight; } #endregion #region Unity /// public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { UxrGrabbableObject grabbableObject = ((MonoBehaviour)property.serializedObject.targetObject).GetComponent(); SerializedProperty propertyGrabPointIndex = property.FindPropertyRelative("_index"); List elements = new List(); for (int i = 0; i < grabbableObject.GrabPointCount; ++i) { elements.Add(UxrGrabPointIndex.GetIndexDisplayName(grabbableObject, i)); } propertyGrabPointIndex.intValue = EditorGUI.Popup(UxrEditorUtils.GetRect(position, 0), property.displayName, propertyGrabPointIndex.intValue, elements.ToArray()); } #endregion } }