Closed wrymn closed 6 days ago
That's a weird one. Easy fix, but not quite how I expected it to work and I'm only seeing it in Unity 2021 (not 2022).
Open LinearMixerTransitionAsset.cs
and add in this line in DoThresholdGUI
at line 208:
if (index > 0)
{
// Stuff.
GUIUtility.GetControlID(FocusType.Passive);// Add this.
}
base.DoThresholdGUI(area, index);
I would have expected it to need to be in an else
after the block where the error icon's GUI.Button
is drawn because it's the presence or absence of the button that's allocating an extra control ID or not and therefore changing the ID of the number field which is what it uses to track the fact that it's the field you're currently editing. But putting it in an else
doesn't fix the issue and this does so I'm not sure what's going on (or why Unity 2022 doesn't have the same issue).
That's a weird one. Easy fix, but not quite how I expected it to work and I'm only seeing it in Unity 2021 (not 2022).
Open
LinearMixerTransitionAsset.cs
and add in this line inDoThresholdGUI
at line 208:if (index > 0) { // Stuff. GUIUtility.GetControlID(FocusType.Passive);// Add this. } base.DoThresholdGUI(area, index);
I would have expected it to need to be in an
else
after the block where the error icon'sGUI.Button
is drawn because it's the presence or absence of the button that's allocating an extra control ID or not and therefore changing the ID of the number field which is what it uses to track the fact that it's the field you're currently editing. But putting it in anelse
doesn't fix the issue and this does so I'm not sure what's going on (or why Unity 2022 doesn't have the same issue).
I have added the check, but the issue still persists. I'm on Unity 2023.2.18
Not sure why 2023 is any different because all the internal stuff looks the same.
Replace the whole method with this:
protected override void DoThresholdGUI(Rect area, int index)
{
var color = GUI.color;
var iconArea = default(Rect);
if (index > 0)
{
var previousThreshold = CurrentThresholds.GetArrayElementAtIndex(index - 1);
var currentThreshold = CurrentThresholds.GetArrayElementAtIndex(index);
if (previousThreshold.floatValue >= currentThreshold.floatValue)
{
iconArea = AnimancerGUI.StealFromRight(
ref area,
area.height,
AnimancerGUI.StandardSpacing);
GUI.color = AnimancerGUI.ErrorFieldColor;
}
}
base.DoThresholdGUI(area, index);
if (iconArea != default)
{
_SortingErrorContent ??= new(AnimancerIcons.Error)
{
tooltip =
"Linear Mixer Thresholds must always be unique" +
" and sorted in ascending order (click to sort)"
};
_SortingErrorStyle ??= new(GUI.skin.label)
{
padding = new(),
};
if (GUI.Button(iconArea, _SortingErrorContent, _SortingErrorStyle))
{
AnimancerGUI.Deselect();
Serialization.RecordUndo(Context.Property);
((LinearMixerTransition)Context.Transition).SortByThresholds();
}
}
GUI.color = color;
}
That fixes it properly by drawing the button after the text field so the button can't interfere with the text.
Not sure why 2023 is any different because all the internal stuff looks the same.
Replace the whole method with this:
protected override void DoThresholdGUI(Rect area, int index) { var color = GUI.color; var iconArea = default(Rect); if (index > 0) { var previousThreshold = CurrentThresholds.GetArrayElementAtIndex(index - 1); var currentThreshold = CurrentThresholds.GetArrayElementAtIndex(index); if (previousThreshold.floatValue >= currentThreshold.floatValue) { iconArea = AnimancerGUI.StealFromRight( ref area, area.height, AnimancerGUI.StandardSpacing); GUI.color = AnimancerGUI.ErrorFieldColor; } } base.DoThresholdGUI(area, index); if (iconArea != default) { _SortingErrorContent ??= new(AnimancerIcons.Error) { tooltip = "Linear Mixer Thresholds must always be unique" + " and sorted in ascending order (click to sort)" }; _SortingErrorStyle ??= new(GUI.skin.label) { padding = new(), }; if (GUI.Button(iconArea, _SortingErrorContent, _SortingErrorStyle)) { AnimancerGUI.Deselect(); Serialization.RecordUndo(Context.Property); ((LinearMixerTransition)Context.Transition).SortByThresholds(); } } GUI.color = color; }
That fixes it properly by drawing the button after the text field so the button can't interfere with the text.
This is working indeed, thank you!
I'll leave this one open so people can see it until Animancer v8.0 releases with the fix.
When changing threshold value in mixer, in the picture bellow, I wanted to type from 1 to 0.3, it always breaks focus and throws this error icon![image](https://github.com/KybernetikGames/animancer/assets/12801017/e1fda8b8-151e-4db6-b022-0faa4383479c)
so as soon as I type first letter, 0, it breaks input focus and then I continue type into nothing![image](https://github.com/KybernetikGames/animancer/assets/12801017/3833426a-3fec-4c01-bef1-e8d0ec8cc91e)
and I just wanted to type valid value, 0.3 for example.
This is super annoying and should be removed. Warning icon can be kept, but the validation of losing focus needs to be removed.