- Home /
Question by
Max-Dep · Oct 22, 2017 at 03:28 PM ·
listeditor-scriptingcustom-inspectorpropertydrawerpopup
DropDownList with string array in Property Drawer
Hello For my first Editor Scripting attempt, there's something I can't figure out. I know It's possible to do dropdown list with enums already automatically, but I have a dynamic list of strings stored into a List that I want to be selectable in the PROPERTY DRAWER. In fact my problem seems partly solved here, except that it's for a Custom Inspector and that I can't figure out how to apply it to to a property drawer
using UnityEngine; using System.Collections; using UnityEditor; using System.Collections.Generic;
[CustomPropertyDrawer(typeof(Anim))] public class InterpolationDrawer : PropertyDrawer {
Rect rect0;
SerializedProperty lchoices;
int choiceIndex = 0;
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
rect0 =
new Rect (
position.x,
position.y,
position.width/3.0f,
position.height
);
lchoices = property.FindPropertyRelative("choices");
EditorGUI.Popup (rect0, choiceIndex, lchoices);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return base.GetPropertyHeight(property,label);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612141612im_/https://answers.unity.com/themes/thub/images/avi.jpg)