22 lines
636 B
C#
Executable File
22 lines
636 B
C#
Executable File
using System.IO;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LoadImageFromStreamingAssets : MonoBehaviour
|
|
{
|
|
public Image LoadToObject;
|
|
public string ImagePathFromStreamingAssets;
|
|
void Start()
|
|
{
|
|
Texture2D texture = new(2,2);
|
|
texture.LoadImage(File.ReadAllBytes(Path.Combine(Application.streamingAssetsPath, ImagePathFromStreamingAssets)));
|
|
|
|
Debug.Log("Loaded texture " + texture.name);
|
|
|
|
if (LoadToObject)
|
|
{
|
|
LoadToObject.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0));
|
|
}
|
|
}
|
|
}
|