Answers for "import image to unity and display"

C#
1

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;
}
Posted by: Guest on May-24-2020
1

load image unity

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

public class LoadLocalMachine : MonoBehaviour {

	// Use this for initialization
	IEnumerator Start () {
		WWW www = new WWW ("file:///D://SampleImage.png");
		while(!www.isDone)
			yield return null;
		GameObject image = GameObject.Find ("RawImage");
		image.GetComponent<RawImage>().texture = www.texture;
	}
}
Posted by: Guest on July-05-2021

C# Answers by Framework

Browse Popular Code Answers by Language