IndieGame/client/Assets/Plugins/Easy Save 3/Scripts/Streams/ES3ResourcesStream.cs

33 lines
682 B
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00
using System.IO;
using UnityEngine;
namespace ES3Internal
{
internal class ES3ResourcesStream : MemoryStream
{
// Check that data exists by checking stream is not empty.
public bool Exists{ get{ return this.Length > 0; } }
// Used when creating
public ES3ResourcesStream(string path) : base(GetData(path))
{
}
private static byte[] GetData(string path)
{
var textAsset = Resources.Load(path) as TextAsset;
// If data doesn't exist in Resources, return an empty byte array.
if(textAsset == null)
return new byte[0];
return textAsset.bytes;
}
protected override void Dispose (bool disposing)
{
base.Dispose(disposing);
}
}
}