Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Fitbie on June 19, 2022, 03:31:16 PM
-
Hi, I'm using the Pixel Crushers Dialogue System Saver (see below). It can save global Playmaker arrays. I have 2 arrays consisting of Scriptable Object 'InvItem' for the inventory. (variable type definition)
https://imgur.com/g5hIy5m
I tried to put my arrays into this script by analogy of bool/float/etc and of course got error "FsmArray' does not contain a definition for 'invitemValues' and no accessible extension method 'invitemValues' accepting a first argument of type 'FsmArray' could be found (are you missing a using directive or an assembly reference?)'
using System;
using System.Collections.Generic;
using UnityEngine;
using HutongGames.PlayMaker;
namespace PixelCrushers
{
/// <summary>
/// Saves a global FsmArray.
/// </summary>
[AddComponentMenu("Pixel Crushers/Third Party/PlayMaker Support/FsmArray Saver")]
public class FsmArraySaver : Saver
{
public string fsmArrayName;
[Serializable]
public class Data
{
public List<bool> boolValues = new List<bool>();
public List<int> intValues = new List<int>();
public List<float> floatValues = new List<float>();
public List<string> stringValues = new List<string>();
}
public override string RecordData()
{
var data = new Data();
var fsmArray = FsmVariables.GlobalVariables.FindFsmArray(fsmArrayName);
if (fsmArray == null) return string.Empty;
if (fsmArray.boolValues != null) data.boolValues.AddRange(fsmArray.boolValues);
if (fsmArray.intValues != null) data.intValues.AddRange(fsmArray.intValues);
if (fsmArray.floatValues != null) data.floatValues.AddRange(fsmArray.floatValues);
if (fsmArray.stringValues != null) data.stringValues.AddRange(fsmArray.stringValues);
return SaveSystem.Serialize(data);
}
public override void ApplyData(string s)
{
var fsmArray = FsmVariables.GlobalVariables.FindFsmArray(fsmArrayName);
if (fsmArray == null) return;
if (string.IsNullOrEmpty(s)) return;
var data = SaveSystem.Deserialize<Data>(s);
if (data == null) return;
fsmArray.boolValues = data.boolValues.ToArray();
fsmArray.intValues = data.intValues.ToArray();
fsmArray.floatValues = data.floatValues.ToArray();
fsmArray.stringValues = data.stringValues.ToArray();
}
}
}
I'm very bad at code, can anyone help? Thank you!
-
Guys I still haven't solved the issue, I need help. If you need more information, let me know.