private static void AddSurrogates(ref SurrogateSelector ss) { Vector2Surrogate Vector2_SS = new Vector2Surrogate(); ss.AddSurrogate(typeof(Vector2), new StreamingContext(StreamingContextStates.All), Vector2_SS); Vector3Surrogate Vector3_SS = new Vector3Surrogate(); ss.AddSurrogate(typeof(Vector3), new StreamingContext(StreamingContextStates.All), Vector3_SS); Vector4Surrogate Vector4_SS = new Vector4Surrogate(); ss.AddSurrogate(typeof(Vector4), new StreamingContext(StreamingContextStates.All), Vector4_SS); ColorSurrogate Color_SS = new ColorSurrogate(); ss.AddSurrogate(typeof(Color), new StreamingContext(StreamingContextStates.All), Color_SS); QuaternionSurrogate Quaternion_SS = new QuaternionSurrogate(); ss.AddSurrogate(typeof(Quaternion), new StreamingContext(StreamingContextStates.All), Quaternion_SS); }
public static bool GetSurrogate(ref object surrogate) { Type objType = surrogate.GetType(); switch (objType.ToString()) { case "UnityEngine.Vector3": surrogate = Vector3Surrogate.GetSurrogateObject((Vector3)surrogate); break; case "UnityEngine.Vector4": surrogate = Vector4Surrogate.GetSurrogateObject((Vector4)surrogate); break; case "UnityEngine.Vector2": surrogate = Vector2Surrogate.GetSurrogateObject((Vector2)surrogate); break; case "UnityEngine.Quaternion": surrogate = QuaternionSurrogate.GetSurrogateObject((Quaternion)surrogate); break; default: return(false); } return(true); }