Search Unity

How do you access 'Image (Script) > Source Image' from a script?

Discussion in 'Getting Started' started by MArafatHossain, Jan 27, 2020.

  1. MArafatHossain

    MArafatHossain

    Joined:
    Jan 26, 2020
    Posts:
    7
    https://imgur.com/a/g47qzBQ

    I'm new to this and I can't seem to understand how to reference button objects 'Image(Script)' components properties. How do you do it?

    I tried:
    this.gameObject.GetComponent<Image>().SourceImage = ClickedButtonIcon;


    Any help in understanding how this works is extremely appreciated.
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    MArafatHossain and JoeStrout like this.
  3. MArafatHossain

    MArafatHossain

    Joined:
    Jan 26, 2020
    Posts:
    7