Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: jrDev on September 16, 2016, 07:26:52 PM
-
Hey guys,
I have this code below where I want to add an object value to an Object Array Type:
object functionResults;
[ArrayEditor(VariableType.Object)]
public FsmArray theFunctionResult;
theFunctionResult.Values = new object[1];
theFunctionResult.Values.SetValue(functionResults, 0);
But this code throws this error "Error Editing Field The Function Result, Cannot Cast from Source Type to Destination Type" when I play it. See pic in attachment. How can I get this to work?
Thanks,
jrDev
-
VariableType.Object refers to a UnityEngine.Object type.
So the array can store UnityEngine.Object references.
object is a system.object type so is incompatible.
What are you trying to store in the FsmArray?
-
Hey,
I want to store text files...
And with that I modified it to say:
[ArrayEditor(typeof(object))]
public FsmArray theFunctionResult;
But this:
theFunctionResult.Values = new object[1];
Doesn't make the arrays length to one, it stays at zero.
Thanks,
jrDev
-
Hey,
Actually after some debug logging, it looks like my object value does get stored in the array based on the above code, it just doesn't show in Playmaker State GUI section. Is this a bug?
Thanks,
jrDev
-
An FsmArray cannot serialize a system.object type. Why not use a string type if you're storing text?
-
An FsmArray cannot serialize a system.object type. Why not use a string type if you're storing text?
Is there a reason why I can't store an system.object type in a Unity.Object type?
Thanks,
jrDev
-
Hi,
Serialization in Unity is complex and indeed System.object and Unity.Object are not the same.
Can you describe the object you are trying to save?
Bye,
Jean