protected override void VisitPath <TContainer, TValue>(Property <TContainer, TValue> property, ref TContainer container, ref TValue value) { switch (Element) { case BaseField <TValue> field: GuiFactory.SetCallbacks(ref value, Path, Root, field); break; case Label label when TypeConversion.TryConvert(value, out string _): GuiFactory.SetCallbacks(ref value, Path, Root, label); break; case BindableElement bindable when TypeConversion.TryConvert(value, out Texture2D _): GuiFactory.SetCallbacks(ref value, Path, Root, bindable); break; default: // Use reflection to figure out if we can map it. TrySetCallbacksThroughReflection(ref value); break; } }
public static void Bind <TValue>(VisualElement element, ref TValue value, PropertyPath path, BindingContextElement root) { switch (element) { case BindingContextElement propertyElement: GuiFactory.SetCallbacks(ref value, path, root, propertyElement); break; case BaseField <TValue> field: GuiFactory.SetCallbacks(ref value, path, root, field); break; case Label label: GuiFactory.SetCallbacks(ref value, path, root, label); break; case BindableElement bindable when element.GetType() == typeof(BindableElement) && TypeConversion.TryConvert(ref value, out Texture2D _): GuiFactory.SetCallbacks(ref value, path, root, bindable); break; default: // Use reflection to figure out if we can map it. TrySetCallbacksThroughReflection(element, ref value, path, root); break; } }
void SetCallbacks <TFieldType, TValue>(ref TValue value, BaseField <TFieldType> field) { GuiFactory.SetCallbacks(ref value, Path, Root, field); }
static void SetCallbacks <TFieldType, TValue>(ref TValue value, BaseField <TFieldType> field, PropertyPath path, BindingContextElement root) { GuiFactory.SetCallbacks(ref value, path, root, field); }