Files
RaindropViewer/Assets/scripts/TGALoader_TestComponent.cs
T
alexiscatnip cdd8470fdf Changed all Bitmap -> Texture2D.
Make demo scene to browse tga files in openmetaverse_data
added BetterStreamingAssets to read from SA
some refactoring.
2021-08-07 00:13:20 +08:00

45 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
namespace Assets
{
[RequireComponent(typeof(RawImage))]
class TGALoader_TestComponent : MonoBehaviour
{
[SerializeField]
public string pathToTGA;
private void Start()
{
if (string.IsNullOrEmpty(pathToTGA))
{
Debug.Log("image directory not specified");
}
float timeStart = Time.realtimeSinceStartup;
var tex = OpenMetaverse.Imaging.LoadTGAClass.LoadTGA(pathToTGA);
float timeEnd = Time.realtimeSinceStartup;
if (tex == null)
{
Debug.Log("reading of TGA at path " + pathToTGA + " failed");
}
else
{
Debug.Log("reading of TGA at path " + pathToTGA + " SUCCESS! \nTook: " + (timeEnd-timeStart) + "seconds");
gameObject.GetComponent<RawImage>().texture = tex;
}
}
}
}