Init repository
This commit is contained in:
Executable file
+21
@@ -0,0 +1,21 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user