// // Methods // public override void OnGUI(SerializedNodeProperty property, ActionNode node, GUIContent guiContent) { UnityVariablePropertyAttribute att = (UnityVariablePropertyAttribute)attribute; BlackboardCustom blackboard = node.blackboard as BlackboardCustom; List <UnityVariable> blackboardLocalList = blackboard.GetVariableBy(att.variableType); List <GUIContent> displayOptionsList = blackboardLocalList.Select((item) => new GUIContent("Local/" + item.name)).ToList(); EditorGUILayout.BeginHorizontal(); // property.serializedNode.ApplyModifiedProperties (); EditorGUI.BeginChangeCheck(); //EditorGUILayout.LabelField (att.name,new GUILayoutOption[]{GUILayout.MaxWidth(80)}); property.value = EditorGUILayoutEx.UnityVariablePopup(new GUIContent(att.name), property.value as UnityVariable, att.variableType, displayOptionsList, blackboardLocalList); if (EditorGUI.EndChangeCheck()) { property.serializedNode.ApplyModifiedProperties(); } EditorGUILayout.EndHorizontal(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Type selectedType = ((UnityVariablePropertyAttribute)attribute).variableType; UnityVariablePropertyAttribute att = (UnityVariablePropertyAttribute)attribute; Blackboard blackboard = GameObject.FindObjectsOfType <Blackboard> ().FirstOrDefault(itm => itm.gameObject.name == att.blackboardName); List <UnityVariable> blackboardLocalList = null; List <GUIContent> displayOptionsList = null; if (blackboard != null) { blackboardLocalList = blackboard.GetVariableBy(att.variableType); displayOptionsList = blackboardLocalList.Select(item => new GUIContent(att.blackboardName + "/" + item.name)).ToList(); } property.objectReferenceValue = EditorGUILayoutEx.UnityVariablePopup(label, property.objectReferenceValue as UnityVariable, selectedType, displayOptionsList, blackboardLocalList, position); property.serializedObject.ApplyModifiedProperties(); }