private static ActivationMode LoopPatternToActivationMode(ItemLoopModePattern loopPattern) { switch (loopPattern) { case ItemLoopModePattern.None: return(ActivationMode.disabled); case ItemLoopModePattern.Yoyo: return(ActivationMode.close); case ItemLoopModePattern.YoyoBranch: return(ActivationMode.closeBranch); case ItemLoopModePattern.Restart: return(ActivationMode.closeImmediately); case ItemLoopModePattern.RestartBranch: return(ActivationMode.closeBranchImmediately); default: return(ActivationMode.disabled); } }
public static void DrawItemProperty(TSSItem item, string propertyName, string displayPropertyName = null, GUILayoutOption displayPropertyOption = null, bool shortCheckBox = false, bool alternative = false) { GUI.color = Color.white; GUI.backgroundColor = Color.white; if (!ItemPropertyIsValid(propertyName)) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox(string.Format(invalidPropertyName.text, propertyName), MessageType.Warning); EditorGUILayout.EndHorizontal(); return; } if (string.IsNullOrEmpty(displayPropertyName)) { displayPropertyName = propertyName; } if (displayPropertyOption == null) { displayPropertyOption = TSSEditorUtils.max100pxWidth; } Type propertyType = GetItemPropertyType(propertyName); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(TSSText.GetHumanReadableString(displayPropertyName), displayPropertyOption); if (propertyType == typeof(float)) { float displayedValue = GetItemValue <float>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <float>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } float enteredValue = Mathf.Clamp(EditorGUILayout.FloatField(displayedValue), 0, float.MaxValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(bool)) { bool displayedValue = GetItemValue <bool>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <bool>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } bool enteredValue = EditorGUILayout.Toggle(displayedValue, shortCheckBox ? TSSEditorUtils.max18pxWidth : TSSEditorUtils.max120pxWidth); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(string)) { string displayedValue = GetItemValue <string>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <string>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } string enteredValue = EditorGUILayout.TextField(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(int)) { int displayedValue = GetItemValue <int>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <int>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } int enteredValue = EditorGUILayout.IntField(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(ChainDirection)) { ChainDirection displayedValue = GetItemValue <ChainDirection>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ChainDirection>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ChainDirection enteredValue = (ChainDirection)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(RotationMode)) { RotationMode displayedValue = GetItemValue <RotationMode>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <RotationMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } RotationMode enteredValue = (RotationMode)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(MaterialMode)) { MaterialMode displayedValue = GetItemValue <MaterialMode>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <MaterialMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } MaterialMode enteredValue = (MaterialMode)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(AnimationCurve)) { AnimationCurve displayedValue = GetItemValue <AnimationCurve>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <AnimationCurve>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } AnimationCurve enteredValue = (AnimationCurve)EditorGUILayout.CurveField(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(TSSProfile)) { TSSProfile displayedValue = GetItemValue <TSSProfile>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <TSSProfile>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } TSSProfile enteredValue = (TSSProfile)EditorGUILayout.ObjectField(displayedValue, typeof(TSSProfile), false); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); if (enteredValue != null && EditorUtility.DisplayDialog(confirmRevertTitle.text, string.Format(confirmRevertMessage.text, item.profile.name), "Yes", "No")) { TSSProfile.ProfileRevert(item, item.profile); } } } else if (propertyType == typeof(ActivationMode)) { if (alternative) { ItemLoopModePattern displayedValue = ActivationModeToLoopPattern(GetItemValue <ActivationMode>(item, propertyName)); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ItemLoopModePattern enteredValue = (ItemLoopModePattern)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, LoopPatternToActivationMode(enteredValue)); } } else { ActivationMode displayedValue = GetItemValue <ActivationMode>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ActivationMode enteredValue = (ActivationMode)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } } else if (propertyType == typeof(ButtonDirection)) { ButtonDirection displayedValue = GetItemValue <ButtonDirection>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ButtonDirection>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ButtonDirection enteredValue = (ButtonDirection)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(ItemUpdateType)) { ItemUpdateType displayedValue = GetItemValue <ItemUpdateType>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ItemUpdateType>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } ItemUpdateType enteredValue = (ItemUpdateType)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } else if (propertyType == typeof(PathNormal)) { PathNormal displayedValue = GetItemValue <PathNormal>(item, propertyName); bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <PathNormal>(propertyName)); if (!itemValuesIdentical) { EditorGUI.showMixedValue = true; } PathNormal enteredValue = (PathNormal)EditorGUILayout.EnumPopup(displayedValue); if (EditorGUI.EndChangeCheck()) { SelectedItemsSetValue(propertyName, enteredValue); } } EditorGUILayout.EndHorizontal(); EditorGUI.showMixedValue = false; }