public static void SaveTransferFunction(TransferFunction tf, string filepath) { TF1DSerialisationData data = new TF1DSerialisationData(); data.version = TF1DSerialisationData.VERSION_ID; data.colourPoints = new List <TFColourControlPoint>(tf.colourControlPoints); data.alphaPoints = new List <TFAlphaControlPoint>(tf.alphaControlPoints); string jsonstring = JsonUtility.ToJson(data); File.WriteAllText(filepath, jsonstring); }
public static TransferFunction LoadTransferFunction(string filepath) { if (!File.Exists(filepath)) { Debug.LogError(string.Format("File does not exist: {0}", filepath)); return(null); } string jsonstring = File.ReadAllText(filepath); TF1DSerialisationData data = JsonUtility.FromJson <TF1DSerialisationData>(jsonstring); Debug.Log(jsonstring); Debug.Log(data.colourPoints.ToString()); Debug.Log(data.alphaPoints.ToString()); TransferFunction tf = new TransferFunction(); tf.colourControlPoints = data.colourPoints; tf.alphaControlPoints = data.alphaPoints; return(tf); }