Skip to content

Commit

Permalink
Merge pull request #176 from AnnulusGames/fix-toggleonlabelclick
Browse files Browse the repository at this point in the history
Fix toggleOnLabelClick does not exist in versions prior to Unity 6
  • Loading branch information
yn01-dev authored Dec 20, 2024
2 parents 357c65b + 9e924d8 commit 62bf062
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public AnimationComponentView()
};
root.Add(foldout);
foldout.Add(new VisualElement() { style = { height = 5f } });
var foldoutCheck = foldout.Q("unity-checkmark");
var foldoutCheck = foldout.Q(className: Foldout.checkmarkUssClassName);
icon = new VisualElement
{
style = {
Expand All @@ -74,12 +74,18 @@ public AnimationComponentView()
foldoutCheck.parent.Add(icon);
enabledToggle = new Toggle
{
toggleOnLabelClick = false,
style = {
unityFontStyleAndWeight = FontStyle.Bold,
}
};
enabledToggle.Q("unity-checkmark").style.marginRight = 6f;
enabledToggle.Q(className: Toggle.checkmarkUssClassName).style.marginRight = 6f;
enabledToggle.schedule.Execute(() =>
{
enabledToggle.pickingMode = PickingMode.Ignore;
enabledToggle.Q(className: Toggle.inputUssClassName).pickingMode = PickingMode.Ignore;
enabledToggle.Q(className: Toggle.textUssClassName).pickingMode = PickingMode.Ignore;
enabledToggle.Q(className: Toggle.checkmarkUssClassName).pickingMode = PickingMode.Position;
});
foldoutCheck.parent.Add(enabledToggle);

progressBar = new ProgressBar
Expand All @@ -96,12 +102,12 @@ public AnimationComponentView()
alignSelf = Align.Stretch,
}
};
var background = progressBar.Q(null, "unity-progress-bar__background");
var background = progressBar.Q(className: AbstractProgressBar.backgroundUssClassName);
background.style.borderTopWidth = 0f;
background.style.borderBottomWidth = 0f;
background.style.borderLeftWidth = 0f;
background.style.borderRightWidth = 0f;
var progress = progressBar.Q(null, "unity-progress-bar__progress");
var progress = progressBar.Q(className: AbstractProgressBar.progressUssClassName);
progress.style.backgroundColor = Color.white;
progress.style.minWidth = 0f;
progressBar.schedule.Execute(() => progress.style.display = progressBar.value > progressBar.lowValue ? DisplayStyle.Flex : DisplayStyle.None).Every(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ AnimationComponentView CreateComponentGUI(SerializedProperty property)
view.Icon = (Texture2D)EditorGUIUtility.IconContent("Error").image;
view.EnabledToggle.value = true;
view.SetEnabled(true);
view.EnabledToggle.toggleOnLabelClick = false;
view.EnabledToggle.Q("unity-checkmark").style.visibility = Visibility.Hidden;
view.Add(new HelpBox("The type referenced in SerializeReference is missing. You may have renamed the type or moved it to a different namespace or assembly.", HelpBoxMessageType.Error));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public override VisualElement CreatePropertyGUI(SerializedProperty property)
var foldout = new Foldout()
{
text = property.displayName,
toggleOnLabelClick = true
};

foldout.BindProperty(property);
Expand Down Expand Up @@ -131,7 +130,6 @@ void FoldoutGroup(VisualElement root, string label, SerializedProperty property,
{
text = label,
style = { marginBottom = 3f },
toggleOnLabelClick = true
};
group.BindProperty(property);
configure(group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public override VisualElement CreatePropertyGUI(SerializedProperty property)
var foldout = new Foldout
{
text = property.displayName,
toggleOnLabelClick = true,
};
foldout.BindProperty(property);

Expand Down

0 comments on commit 62bf062

Please sign in to comment.