How to have get button display a raw image?

Hi, currently I’m trying to get a button to display a raw image. I have the game objects set-up in the canvas I just don’t know how to get the image to be invisible when the scene loads and then when the button is clicked to have the image appear.

For context this is for a character selection screen and I’m wanting the image of the player character to display when the character head shot is clicked on.

Disable the gameObject with the image, and have the button activate it when clicked.


If I have understood your problem correctly, solution is below:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class abc : MonoBehaviour {
	public Button xyz; // button to be clicked
	public Sprite change_texture; // texture you want to assign on button click
	// Use this for initialization
	void Start () {


	// Update is called once per frame
	public void ButtonClicked ()
		xyz.GetComponent<Image>().sprite = change_texture; // on clicking button sprite would change

Also don’t forget to assign button function to be called on buttonclick from inspector.ScreenShot is attached. Script is attached to main camera.

I hope your problem gets solved.Have a good Day!!

When I Put characters in rawimage button how can you do levelmanager and character select at the same