static void CreateSurrogates() { ss = new SurrogateSelector(); //VECTOR2 Vector2SerializationSurrogate v2_ss = new Vector2SerializationSurrogate(); ss.AddSurrogate(typeof(Vector2), new StreamingContext(StreamingContextStates.All), v2_ss); //VECTOR3 Vector3SerializationSurrogate v3_ss = new Vector3SerializationSurrogate(); ss.AddSurrogate(typeof(Vector3), new StreamingContext(StreamingContextStates.All), v3_ss); //VECTOR4 Vector4SerializationSurrogate v4_ss = new Vector4SerializationSurrogate(); ss.AddSurrogate(typeof(Vector4), new StreamingContext(StreamingContextStates.All), v4_ss); //QUATERNION QuaternionSerializationSurrogate q_ss = new QuaternionSerializationSurrogate(); ss.AddSurrogate(typeof(Quaternion), new StreamingContext(StreamingContextStates.All), q_ss); //COLOR AND COLOR32 ColorSerializationSurrogate color_ss = new ColorSerializationSurrogate(); ss.AddSurrogate(typeof(Color), new StreamingContext(StreamingContextStates.All), color_ss); ss.AddSurrogate(typeof(Color32), new StreamingContext(StreamingContextStates.All), color_ss); //TEXTURE2D Texture2DSerializationSurrogate texture_ss = new Texture2DSerializationSurrogate(); ss.AddSurrogate(typeof(Texture2D), new StreamingContext(StreamingContextStates.All), texture_ss); Texture2DCompressionType_old = Texture2DCompressionType; }
public static void AddAllUnitySurrogate(this SurrogateSelector surrogateSelector) { var colorSS = new ColorSerializationSurrogate(); var quaternionSS = new QuaternionSerializationSurrogate(); var vector2IntSS = new Vector2IntSerializationSurrogate(); var vector2SS = new Vector2SerializationSurrogate(); var vector3IntSS = new Vector3IntSerializationSurrogate(); var vector3SS = new Vector3SerializationSurrogate(); var vector4SS = new Vector4SerializationSurrogate(); surrogateSelector.AddSurrogate(typeof(Color), new StreamingContext(StreamingContextStates.All), colorSS); surrogateSelector.AddSurrogate(typeof(Quaternion), new StreamingContext(StreamingContextStates.All), quaternionSS); surrogateSelector.AddSurrogate(typeof(Vector2Int), new StreamingContext(StreamingContextStates.All), vector2IntSS); surrogateSelector.AddSurrogate(typeof(Vector2), new StreamingContext(StreamingContextStates.All), vector2SS); surrogateSelector.AddSurrogate(typeof(Vector3Int), new StreamingContext(StreamingContextStates.All), vector3IntSS); surrogateSelector.AddSurrogate(typeof(Vector3), new StreamingContext(StreamingContextStates.All), vector3SS); surrogateSelector.AddSurrogate(typeof(Vector4), new StreamingContext(StreamingContextStates.All), vector4SS); }