Image unity code example

Example 1: public image unity

using UnityEngine;  using System.Collections; using UnityEngine.UI;  public class Radar : MonoBehaviour {   public Image Arrow;  void OnTriggerEnter( Collider other) {      if (other.gameObject.tag == "Enemy")          Arrow.gameObject.SetActive(true);  } }

Example 2: unity image

//Make sure you are using UnityEngine.UI
using UnityEngine.UI

//We can assign this image in the inspector
public Image image;
//Also assign this in the inspector
public Sprite mySprite;

public void ChangeImage () 
{
	image.sprite = mySprite;
}

Tags:

Css Example