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

Changing Button Image On Click (Javascript)

Discussion in 'UGUI & TextMesh Pro' started by Fireking883, Mar 25, 2017.

  1. Fireking883

    Fireking883

    Joined:
    Nov 28, 2014
    Posts:
    50
    Exactly what the title says. I have tried looking it up but nothing seems to work. The last thing I tried was:
    Code (JavaScript):
    1.      if(BID == 1){
    2.          B1.GetComponent.<Image>() = CubeButton;
    Which gives the error: Assets/Inventory.js(96,41): BCE0049: Expression 'self.B1.GetComponent[of UnityEngine.UI.Image]()' cannot be assigned to.

    I am just trying to change the button image to an image of a cube when I click on it.
     
  2. mikael_juhala

    mikael_juhala

    Joined:
    Mar 9, 2015
    Posts:
    247