| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | using System;using UnityEngine;public class TextureResource{	public TextureResource(int width, int height, TextureFormat format, Rect[] uvRects, byte[] data)	{		this.width = width;		this.height = height;		this.format = format;		this.uvRects = null;		if (uvRects != null && 0 < uvRects.Length)		{			this.uvRects = new Rect[uvRects.Length];			Array.Copy(uvRects, this.uvRects, uvRects.Length);		}		this.data = data;	}	public Texture2D CreateTexture2D()	{		if (this.format == TextureFormat.DXT1 || this.format == TextureFormat.DXT5)		{			Texture2D texture2D = new Texture2D(this.width, this.height, this.format, false);			texture2D.LoadRawTextureData(this.data);			texture2D.Apply();			return texture2D;		}		if (this.format == TextureFormat.ARGB32 || this.format == TextureFormat.RGB24)		{			Texture2D texture2D2 = new Texture2D(2, 2, this.format, false);			texture2D2.LoadImage(this.data);			return texture2D2;		}		Debug.LogError("format:" + this.format.ToString() + "は対応していません");		return null;	}	public readonly int width;	public readonly int height;	public readonly TextureFormat format;	public readonly Rect[] uvRects;	public readonly byte[] data;}
 |