I created a custom element and am trying to use UQuery
to find different ones but have come up against a very strange issue that I don’t understand.
On Start
, I can call this and it works:
VisualElement Otpb = v_ActiveGameDisplay.Q<VisualElement>("Openness-tpb");
TreatmentTraitProgressBar O = Otpb.Q<TreatmentTraitProgressBar>();
Debug.Log(O.value);
But, the following does not work. It finds the Label
but not the custom TreatmentTraitProgressBar
, which just seems odd.
v_ActiveGameDisplay.Query<VisualElement>().ForEach((element) => {
if (element.name.Contains(trait.name.ToString()))
{
TreatmentTraitProgressBar ttpb = element.Q<TreatmentTraitProgressBar>();
Label l = element.Q<Label>();
}
});
Any help would be greatly appreciated, thank you!