playMaker

Author Topic: ParseValueToString type not supported UnityEngine.Texture2D  (Read 2733 times)

liversmudge

  • Playmaker Newbie
  • *
  • Posts: 4
ParseValueToString type not supported UnityEngine.Texture2D
« on: February 07, 2014, 11:24:29 AM »
Hi Jean

I bought the easy2save plug-in a week or so ago. (I know its not your plugin)

I seem to have most elements working, but have difficulty saving from web using arraymaker.

The issue is saving a texture, I can add it to the array, and see it in the content section of the Hash Table Proxy.

I get the error

ParseValueToString type not supported UnityEngine.Texture2D

Then there seems to be a timeout on the save, no data sent to the php script.

I dont know if this is a playmaker or an easy save issue.

I did email Joel he said this error is not one that Easy save can throw, any ideas?

Thanks

L

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ParseValueToString type not supported UnityEngine.Texture2D
« Reply #1 on: February 10, 2014, 02:48:00 AM »
Hi,

 Currently this is not supported unfortunatly. I can't find a way to properly serialize a texture into a string back and forth.

 I would suggest simply saving a reference of that texture. Is your texture a user content ( like a webcam screenshot or something)?

bye,

 Jean

liversmudge

  • Playmaker Newbie
  • *
  • Posts: 4
Re: ParseValueToString type not supported UnityEngine.Texture2D
« Reply #2 on: February 13, 2014, 04:12:10 PM »
Yes it is, needs to be shared so has to be save to web.

So saving a ref to the texture isnt quite what I need.

Sadly Im going to have to look for another method to store the images. I really hoped that this would do the trick, hence why I bought easy save.

Thanks anyway.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ParseValueToString type not supported UnityEngine.Texture2D
« Reply #3 on: February 13, 2014, 11:26:33 PM »
Hi,

 The next task I will tackle will be ArrayMaker. I'll get in touch with Easysave to see if they can expose a bit more of their internal work, basically, they have everything but I can't access it, only throuhg saving and loading, where I would simply need to "get" it in a variable, and then I could save everything easySave supports from a hashtable.

bye,

 Jean

liversmudge

  • Playmaker Newbie
  • *
  • Posts: 4
Re: ParseValueToString type not supported UnityEngine.Texture2D
« Reply #4 on: February 16, 2014, 09:02:42 AM »
I am using the following to convert to a string. It seems to work.

using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;
using System;

[ActionCategory("Easy Save 2")]
[Tooltip("Convet Texture To String")]

public class texureString : FsmStateAction
{
   [ActionSection("Set up")]
   [RequiredField]
   [Tooltip("Texture To Convert")]
   public FsmTexture myTexture;

   [ActionSection("Result")]
   [RequiredField]
   [Tooltip("Target String")]
   public FsmString myString;

   public override void Reset()
   {
      // nothing needed here
   }
   
   // Code that runs on entering the state.
   public override void OnEnter()
   {
      // find the texture
      Texture2D tex;
      byte[] byteArray;

      // (xxx.GetTexture() as Texture2D)
      tex = (myTexture.Value as Texture2D);

      // convert

      byteArray=tex.EncodeToPNG();
      string temp=Convert.ToBase64String(byteArray);

      // save
      myString.Value = temp;

      Finish();
   }
}

liversmudge

  • Playmaker Newbie
  • *
  • Posts: 4
Re: ParseValueToString type not supported UnityEngine.Texture2D
« Reply #5 on: February 16, 2014, 09:03:52 AM »
This to convert back to texture

using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;
using System;

[ActionCategory("Easy Save 2")]
[Tooltip("Convet Texture To String")]

public class texureFromString : FsmStateAction
{
   [ActionSection("Set up")]
   [RequiredField]
   [Tooltip("String To Convert")]
   public FsmString myString;

   [Tooltip("Width")]
   public FsmInt width;
   
   [Tooltip("Height")]
   public FsmInt height;

   [ActionSection("Result")]
   [RequiredField]
   [Tooltip("Target texture")]
   public FsmTexture myTexture;
   
   public override void Reset()
   {
      // nothing needed here
   }
   
   // Code that runs on entering the state.
   public override void OnEnter()
   {
      
      byte[] byteArray= Convert.FromBase64String(myString.Value);
      
      Texture2D tex = new Texture2D(width.Value,height.Value);
      
      tex.LoadImage(byteArray);

      myTexture.Value = (tex as Texture2D);
      
      Finish();
   }
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ParseValueToString type not supported UnityEngine.Texture2D
« Reply #6 on: February 17, 2014, 11:38:21 PM »
Hi,

 excellent! how did I miss this.... sorry about that. It's been added.

Can you replace the file attached in your project, it will then support texture serialization.

This will be part of the coming soon arrayMaker update.

Thanks again liversmudge :)

Bye,

 Jean