You can bind to any field that is backed by Serialization, which includes the Editor’s fields. If you need to change the data, you can write the final result to a field and bind to that. If you’re on 2023.2 (and newer), you can use the new binding system for UI which allows for custom modifiers for your bindings. More here: https://docs.unity3d.com/2023.2/Documentation/Manual/UIE-comparison-binding.html
Only if the TextField’s name is not unique enough. This is why it’s recommended to use the BEM pattern for naming elements and classes so you can do a single query: https://getbem.com/naming/
This is not the same as view binding that I see when working with Android UI right.
Would be convenient to have some Attribute that automatically fills up fields of a class with their UXML counterparts. So that I don’t have to root.Q finding for each element.
You’ll have to forgive if this is all wrong, like most things this seems to be stumbling through documentation, experimentation and shouting into the void.
Create a Scriptable Object – so new MonoBehaviour Script
Forgive the names – this one is CatDataScriptableObject – to bind a progress bar to how fast it’s running.
[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/CatDataScriptableObject", order =1)]
public class CatDataScriptableObject : ScriptableObject
{
public float RunSpeed;
}
Because of the attributes, I can now create an instance of this with:
In the inspector I can see that is has my property.
In a script that I have for my UI – I add a field for this.
public class UI_Script : MonoBehaviour
{
public PlayerController playerController;
// Expose this as a property.
public CatDataScriptableObject catDataScriptableObject;
...
and at some point in the code, I update the value. Back to the inspector I drag the instance I created above into this.