private float PrefabHeight(int index) { SerializedProperty element = prefabList.serializedProperty.GetArrayElementAtIndex(index); float itemHeight = lineHeight + 3; float height = itemHeight * 4; WorldObjectType.SkinPrefabMapping.ChangeType changeType = (WorldObjectType.SkinPrefabMapping.ChangeType)element.FindPropertyRelative("changeType").enumValueIndex; if (changeType == WorldObjectType.SkinPrefabMapping.ChangeType.ToggleActive) { height += itemHeight * 2; } SerializedProperty inventorySlotConditions = element.FindPropertyRelative("inventorySlotConditions"); if (inventorySlotConditions.isExpanded) { height += itemHeight; height += itemHeight * element.FindPropertyRelative("inventorySlotConditions").arraySize; } if (worldObjectType.completeType != WorldObjectType.CompleteType.None) { height += itemHeight; } if (worldObjectType.canBeDamaged) { height += itemHeight; } if (worldObjectType.states != null && worldObjectType.states.Count > 0) { height += itemHeight; SerializedProperty states = element.FindPropertyRelative("states"); if (states.isExpanded) { height += itemHeight; height += itemHeight * element.FindPropertyRelative("states").arraySize; } } return(height + 10); }
void DrawPrefabListItems(Rect rect, int index, bool isActive, bool isFocused) { SerializedProperty element = prefabList.serializedProperty.GetArrayElementAtIndex(index); float itemWidth = EditorGUIUtility.currentViewWidth - 75; float itemHeight = lineHeight + 3; float currentY = rect.y + 7; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), element.FindPropertyRelative("changeType")); WorldObjectType.SkinPrefabMapping.ChangeType changeType = (WorldObjectType.SkinPrefabMapping.ChangeType)element.FindPropertyRelative("changeType").enumValueIndex; if (changeType == WorldObjectType.SkinPrefabMapping.ChangeType.ReplaceGameObject) { currentY += itemHeight; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), element.FindPropertyRelative("prefab")); } else { currentY += itemHeight; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), element.FindPropertyRelative("enableType")); currentY += itemHeight; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), element.FindPropertyRelative("disableType")); currentY += itemHeight; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), element.FindPropertyRelative("childStartIndex")); } currentY += itemHeight; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), element.FindPropertyRelative("prefabVariantIndex")); if (worldObjectType.completeType != WorldObjectType.CompleteType.None) { currentY += itemHeight; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth / 2f + 10, lineHeight), element.FindPropertyRelative("minComplete"), new GUIContent("Complete Range", "Set both to -1 to ignore")); GUI.Label(new Rect(rect.x + itemWidth / 2f + 12, currentY, 10, lineHeight), "-"); EditorGUI.PropertyField(new Rect(rect.x + itemWidth / 2f + 23, currentY, 35, lineHeight), element.FindPropertyRelative("maxComplete"), GUIContent.none); } if (worldObjectType.canBeDamaged) { currentY += itemHeight; EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth / 2f + 10, lineHeight), element.FindPropertyRelative("minDamage"), new GUIContent("Damage Range", "Set both to -1 to ignore")); GUI.Label(new Rect(rect.x + itemWidth / 2f + 12, currentY, 10, lineHeight), "-"); EditorGUI.PropertyField(new Rect(rect.x + itemWidth / 2f + 23, currentY, 35, lineHeight), element.FindPropertyRelative("maxDamage"), GUIContent.none); } currentY += itemHeight; SerializedProperty inventorySlotConditions = element.FindPropertyRelative("inventorySlotConditions"); EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), inventorySlotConditions); if (inventorySlotConditions.isExpanded) { EditorGUI.indentLevel++; currentY += itemHeight; inventorySlotConditions.arraySize = EditorGUI.DelayedIntField(new Rect(rect.x, currentY, itemWidth, lineHeight), "How Many Slot Conditions?", inventorySlotConditions.arraySize); for (int i = 0; i < inventorySlotConditions.arraySize; i++) { currentY += itemHeight; SerializedProperty inventorySlotCondition = inventorySlotConditions.GetArrayElementAtIndex(i); EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), inventorySlotCondition, new GUIContent("Slot Condition #" + (i + 1))); } EditorGUI.indentLevel--; } if (worldObjectType.states != null && worldObjectType.states.Count > 0) { currentY += itemHeight; SerializedProperty states = element.FindPropertyRelative("states"); EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), states); if (states.isExpanded) { EditorGUI.indentLevel++; currentY += itemHeight; states.arraySize = EditorGUI.DelayedIntField(new Rect(rect.x, currentY, itemWidth, lineHeight), "How Many States?", states.arraySize); for (int i = 0; i < states.arraySize; i++) { currentY += itemHeight; SerializedProperty state = states.GetArrayElementAtIndex(i); EditorGUI.PropertyField(new Rect(rect.x, currentY, itemWidth, lineHeight), state, new GUIContent("State #" + (i + 1))); } EditorGUI.indentLevel--; } } }