0
SerializationException: Type UnityEngine.Vector3 is not marked as Serializable.
私はドキュメントを見てみると私はSerializableタイプのこのリストにするVector3を参照してください。
Serializable types are:
- Some built-in types like Vector2, Vector3, Vector4, Quaternion, Matrix4x4, Color, Rect, LayerMask.
私のコードは次のとおりです。
public Options_Settings GameOptions { get; private set; }
public void SaveOptionSettings(){
// Create the Binary Formatter.
BinaryFormatter bf = new BinaryFormatter();
// Stream the file with a File Stream. (Note that File.Create() 'Creates' or 'Overwrites' a file.)
FileStream file = File.Create(Application.persistentDataPath + "/OptionsInfo.dat");
// Serialize the file so the contents cannot be manipulated.
bf.Serialize(file, GameOptions); // <---- Error is here
// Close the file to prevent any corruptions
file.Close();
}
私のOpti ons_Settings:ドキュメントが私と言うので、私は私が回避策を作り、ちょうど各ベクトルのための3台の山車を作り、その道の周りにそれらを渡すことができます知っているが、私は私が間違っているのかを理解したい
using UnityEngine;
using System;
[Serializable]
public class Options_Settings {
public bool MusicToggle { get; set; }
public float MusicVolume { get; set; }
public bool SFXToggle { get; set; }
public float SFXVolume { get; set; }
public Vector3 UIOneScaling { get; set; }
public Vector3 UITwoScaling { get; set; }
public Vector3 UIThreeScaling { get; set; }
public void Default() {
MusicToggle = true;
MusicVolume = 0.5f;
SFXToggle = true;
SFXVolume = 0.5f;
UIOneScaling = Vector3.one;
UITwoScaling = Vector3.one;
UIThreeScaling = Vector3.one;
}
}
余分なコーディングを防ぎ、単調な動作をするVector3を行うことができます。
[serialization surrogates](http://web.archive.org/web/20141231105711/http://msdn.microsoft.com/en-us/magazine/cc188950.aspx)を使用してください。 http://forum.unity3d.com/threads/vector3-not-serializable.7766/を参照してください。 – dbc