예제 #1
0
        private static Texture2D CreateTexture2D(StorableTexture storableTexture, IEnumerable <Color32> colors)
        {
            var texture = new Texture2D(storableTexture.Width, storableTexture.Height, storableTexture.TextureFormat, storableTexture.MipChain);

            texture.SetPixels32(colors.ToArray());
            texture.Apply();
            return(texture);
        }
예제 #2
0
 public IObservable <Unit> WriteAsObservable(Uri uri, StorableTexture entity)
 {
     return(Observable
            .Zip(
                // SerializeField を JSON に Serialize してから保存
                WriteAsObservable(new UriBuilder(uri)
     {
         Path = $"{uri.AbsolutePath}.info.bytes"
     }.Uri, Encoding.UTF8.GetBytes(JsonUtility.ToJson(entity))),
                // 画像データを保存
                WriteAsObservable(new UriBuilder(uri)
     {
         Path = $"{uri.AbsolutePath}.data.bytes"
     }.Uri, entity.Data)
                )
            .AsUnitObservable());
 }