Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: liversmudge 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
-
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
-
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.
-
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
-
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();
}
}
-
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();
}
}
-
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