private void DrawPropertyIndex(Guid id, ThemeTargetEditorUtils.SelectionState selectionState, AnimBool animBool) { GUILayout.Space(DGUI.Properties.Space(2)); int propertyIndex = m_theme.GetSpritePropertyIndex(id); bool propertyNotFound = id == Guid.Empty || propertyIndex == -1; DGUI.Bar.Draw(selectionState + (propertyNotFound ? "" : ": " + m_theme.SpriteLabels[propertyIndex].Label), Size.L, DGUI.Bar.Caret.CaretType.Caret, ComponentColorName, animBool); if (DGUI.FoldOut.Begin(animBool)) { GUILayout.Space(DGUI.Properties.Space(2)); if (propertyNotFound) { ThemeTargetEditorUtils.DrawLabelNoPropertyFound(); } else { DrawSpriteProperties(m_theme, propertyIndex, selectionState); } } DGUI.FoldOut.End(animBool); }
private void DrawSpriteProperties(ThemeData themeData, int propertyIndex, ThemeTargetEditorUtils.SelectionState selectionState) { GUIStyle buttonStyleDisabled = Styles.GetStyle(Styles.StyleName.CheckBoxDisabled); GUIStyle buttonStyleEnabled = Styles.GetStyle(Styles.StyleName.CheckBoxEnabled); for (var i = 0; i < themeData.SpriteLabels.Count; i++) { LabelId spriteProperty = themeData.SpriteLabels[i]; int index = i; bool selected = i == propertyIndex; GUILayout.BeginHorizontal(); { GUI.color = DGUI.Colors.PropertyColor(ComponentColorName); if (GUILayout.Button(GUIContent.none, selected ? buttonStyleEnabled : buttonStyleDisabled)) { if (serializedObject.isEditingMultipleObjects) { DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue); foreach (Object o in targets) { var themeTarget = (SpriteTargetSelectable)o; if (themeTarget == null) { continue; } switch (selectionState) { case ThemeTargetEditorUtils.SelectionState.Highlighted: themeTarget.HighlightedSpritePropertyId = themeData.SpriteLabels[index].Id; break; case ThemeTargetEditorUtils.SelectionState.Pressed: themeTarget.PressedSpritePropertyId = themeData.SpriteLabels[index].Id; break; #if UNITY_2019_3_OR_NEWER case ThemeTargetEditorUtils.SelectionState.Selected: themeTarget.SelectedSpritePropertyId = themeData.SpriteLabels[index].Id; break; #endif case ThemeTargetEditorUtils.SelectionState.Disabled: themeTarget.DisabledSpritePropertyId = themeData.SpriteLabels[index].Id; break; } themeTarget.UpdateTarget(themeData); } } else { DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue); switch (selectionState) { case ThemeTargetEditorUtils.SelectionState.Highlighted: Target.HighlightedSpritePropertyId = themeData.SpriteLabels[index].Id; break; case ThemeTargetEditorUtils.SelectionState.Pressed: Target.PressedSpritePropertyId = themeData.SpriteLabels[index].Id; break; #if UNITY_2019_3_OR_NEWER case ThemeTargetEditorUtils.SelectionState.Selected: Target.SelectedSpritePropertyId = themeData.SpriteLabels[index].Id; break; #endif case ThemeTargetEditorUtils.SelectionState.Disabled: Target.DisabledSpritePropertyId = themeData.SpriteLabels[index].Id; break; } Target.UpdateTarget(themeData); } } GUI.color = InitialGUIColor; GUILayout.Space(DGUI.Properties.Space(2)); GUI.enabled = selected; DGUI.Label.Draw(spriteProperty.Label, selected ? Size.L : Size.M); GUI.enabled = true; } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space()); } }