// Draw the property inside the given rect public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); float x = position.x; float y = position.y + 5f; float w = position.width - 5f; //float w2 = position.width / 8f; float h = position.height; float lineH = 18f; GUI.Box(position, ""); EventScript.E_ModifierTargetType type = (EventScript.E_ModifierTargetType)property.FindPropertyRelative("targetType").enumValueIndex; var typeRect = new Rect(x, y, w, lineH); SerializedProperty typeProp = property.FindPropertyRelative("targetType"); EditorGUI.PropertyField(typeRect, typeProp); switch (type) { case EventScript.E_ModifierTargetType.item: SerializedProperty itemProp = property.FindPropertyRelative("itemChange"); float itemH = EditorGUI.GetPropertyHeight(itemProp); var itemRect = new Rect(x, y + lineH, w, itemH); EditorGUI.PropertyField(itemRect, itemProp); break; case EventScript.E_ModifierTargetType.dictionary: SerializedProperty dictProp = property.FindPropertyRelative("dictionaryChange"); float dictH = EditorGUI.GetPropertyHeight(dictProp); var dictRect = new Rect(x, y + lineH, w, dictH); EditorGUI.PropertyField(dictRect, dictProp); break; case EventScript.E_ModifierTargetType.quest: SerializedProperty questProp = property.FindPropertyRelative("questChange"); float questH = EditorGUI.GetPropertyHeight(questProp); var questRect = new Rect(x, y + lineH, w, questH); EditorGUI.PropertyField(questRect, questProp); break; case EventScript.E_ModifierTargetType.timeline: SerializedProperty historyProp = property.FindPropertyRelative("historyEvent"); float histH = EditorGUI.GetPropertyHeight(historyProp); var histRect = new Rect(x, y + lineH, w, histH); EditorGUI.PropertyField(histRect, historyProp, true); break; case EventScript.E_ModifierTargetType.gamelog: SerializedProperty gamelogProp = property.FindPropertyRelative("newGameLog"); float loggerH = EditorGUI.GetPropertyHeight(gamelogProp); var loggerRect = new Rect(x, y + lineH, w, loggerH); EditorGUI.PropertyField(loggerRect, gamelogProp, true); break; } EditorGUI.EndProperty(); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float h = 24f; EventScript.E_ModifierTargetType type = (EventScript.E_ModifierTargetType)property.FindPropertyRelative("targetType").enumValueIndex; switch (type) { case EventScript.E_ModifierTargetType.item: SerializedProperty itemProp = property.FindPropertyRelative("itemChange"); float itemH = EditorGUI.GetPropertyHeight(itemProp); h += itemH; break; case EventScript.E_ModifierTargetType.dictionary: SerializedProperty dictProp = property.FindPropertyRelative("dictionaryChange"); float dictH = EditorGUI.GetPropertyHeight(dictProp); h += dictH; break; case EventScript.E_ModifierTargetType.quest: SerializedProperty questProp = property.FindPropertyRelative("questChange"); float questH = EditorGUI.GetPropertyHeight(questProp); h += questH; break; case EventScript.E_ModifierTargetType.timeline: SerializedProperty historyProp = property.FindPropertyRelative("historyEvent"); float histH = EditorGUI.GetPropertyHeight(historyProp); h += histH; break; case EventScript.E_ModifierTargetType.gamelog: SerializedProperty gamelogProp = property.FindPropertyRelative("newGameLog"); float loggerH = EditorGUI.GetPropertyHeight(gamelogProp); h += loggerH; break; } return(h); }