Home Game Development Unity UI Toolkit | Select Background Image and Position of a VisualElement

Unity UI Toolkit | Select Background Image and Position of a VisualElement

0
Unity UI Toolkit | Select Background Image and Position of a VisualElement

[ad_1]

I’m looking now for nearly an hour and I can’t determine how appropriately to pick out the background picture and place of a visible factor.

The question docu is absolutely poor, there’s actually nothing:

UQuery is a set of extension strategies permitting you to pick out particular person or assortment of visualElements inside a fancy hierarchy.

All the youtube guys present the identical instance with a Button.

I’ve this construction:

https://imgur.com/p6qrVbP

Each “Layer” accommodates a background picture:

enter image description here

Here is my code:

    public class ParallaxController : MonoBehaviour {
 
    public VisualElement layer_0;
    public Image layer_0_0;
    public Image layer_1;
    public Image layer_1_1;
    public Image layer_2;
    public Image layer_2_2;
    public Image layer_3;
    public Image layer_3_3;
    public Image layer_4;
    public Image layer_4_4;
 
    // Start is named earlier than the primary body replace
    void Start() {
        var root = GetComponent<UIDocument>().rootVisualElement;
 
        layer_0 = root.Q<VisualElement>("Layer_0");
        Debug.Log(layer_0.fashion.backgroundImage);
        Debug.Log(layer_0.fashion.backgroundImage.worth.sprite);
        Debug.Log(layer_0.fashion.backgroundImage.worth.texture);
        Debug.Log(layer_0.fashion.place);
        //Debug.Log(layer_0.Q.<Image>());
        //Debug.Log(layer_0.Q.<Background>());
    }
 
    // Update is named as soon as per body
    void Update() {
     
    }
}

Its all the time Null

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here