Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to create a array?

Discussion in 'Getting Started' started by Catdog33233, Feb 22, 2021.

  1. Catdog33233

    Catdog33233

    Joined:
    Sep 10, 2020
    Posts:
    2
    I want to repeat a image as the background of the canvas using code, How do I do this?
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    What do you need the array for? Why do this in code versus using the UI components? If it's just for practice and learning purposes, you may want to learn about how the UI works a bit more first.
     
    Joe-Censored likes this.
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'd do this with a RawImage object. It allows you to specify the UV coordinates used; assuming your texture is set to Wrap rather than Clamp, you just set your UV coordinates to cover a large range (like 0-10) to get many repeats of the texture in one UI object.
     
    Joe-Censored likes this.
  4. Catdog33233

    Catdog33233

    Joined:
    Sep 10, 2020
    Posts:
    2
    I want to change the background to other things than the array and im not sure how i could do that with only UI