BITFALL/Assets/Plugins/Polaris - Low Poly Ecosystem/Polaris - Low Poly Terrain .../Runtime/Scripts/Utilities/GTextureNativeDataDescripto...

53 lines
1.1 KiB
C#
Raw Normal View History

2024-03-05 17:34:41 +08:00
#if GRIFFIN
2023-12-30 17:37:48 +08:00
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
namespace Pinwheel.Griffin
{
public struct GTextureNativeDataDescriptor<T> where T : struct
{
[ReadOnly]
public NativeArray<T> data;
public int width;
public int height;
private bool isValid;
public bool IsValid
{
get
{
return isValid;
}
}
public GTextureNativeDataDescriptor(Texture2D tex)
{
if (tex != null)
{
data = tex.GetRawTextureData<T>();
width = tex.width;
height = tex.height;
isValid = true;
}
else
{
data = new NativeArray<T>(1, Allocator.Persistent);
width = 0;
height = 0;
isValid = false;
}
}
public void Dispose()
{
if (!isValid)
{
GNativeArrayUtilities.Dispose(data);
}
}
}
}
2024-03-05 17:34:41 +08:00
#endif