Esempio n. 1
0
 private int GetCurrentIndex(StringPopupAttribute attribute, SerializedProperty property)
 {
     for (int i = 0; i < attribute.value.Length; i++)
     {
         if (attribute.value[i] == property.stringValue)
         {
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 2
0
 public override bool CanCacheInspectorGUI(SerializedProperty property)
 {
     if (property.type == "string")
     {
         stringPopup  = attribute as StringPopupAttribute;
         currentIndex = GetCurrentIndex(stringPopup, property);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        StringPopupAttribute pa = this.attribute as StringPopupAttribute;

        if (property.depth <= 0)
        {
            position.xMin += 4;
        }
        int selected = System.Array.FindIndex(pa.OptionValues, value => value == property.stringValue);

        selected = selected >= 0 ? selected : 0;
        selected = EditorGUI.Popup(position, pa.Lable, selected, pa.OptionValues);
        if (GUI.changed)
        {
            property.stringValue = pa.OptionValues[selected];
        }
    }