/// <summary> /// Gets the height needed for drawing the property /// </summary> /// <param name="property"></param> /// <param name="label"></param> /// <returns></returns> public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { CommandsBehaviour commandsBehaviour = GameObject.FindObjectOfType <CommandsBehaviour>(); if (commandsBehaviour == null) { return(base.GetPropertyHeight(property, label) * 2.0f); } return(base.GetPropertyHeight(property, label)); }
/// <summary> /// Draws popup in the Inspector /// </summary> /// <param name="position"></param> /// <param name="property"></param> /// <param name="label"></param> public override void OnGUI(UnityEngine.Rect position, SerializedProperty property, UnityEngine.GUIContent label) { CommandsBehaviour commandsBehaviour = GameObject.FindObjectOfType <CommandsBehaviour>(); if (commandsBehaviour == null) { EditorGUI.HelpBox(position, "Can not find a CommandsBehaviour component in the scene.", MessageType.Warning); return; } List <RepliesSet> repliesSets = commandsBehaviour.GetRepliesSets().ToList(); string[] displayOptions = repliesSets.Select(x => x.message).ToArray(); int index = repliesSets.FindIndex(x => x.message == property.stringValue); index = EditorGUI.Popup(position, label.text, index, displayOptions); if (index > -1) { property.stringValue = displayOptions[index]; } }