using System; namespace Unity.Netcode { /// /// Marks a generic parameter in this class as a type that should be serialized through /// . This enables the use of the following methods to support /// serialization within a Network Variable type: ///
///
/// . ///
/// . ///
/// . ///
/// . ///
///
/// The parameter is indicated by index (and is 0-indexed); for example: ///
/// /// [SerializesGenericParameter(1)] /// public class MyClass<TTypeOne, TTypeTwo> /// { /// } /// ///
/// This tells the code generation for to generate /// serialized code for TTypeTwo (generic parameter 1). ///
///
/// Note that this is primarily intended to support subtypes of , /// and as such, the type resolution is done by examining fields of /// subclasses. If your type is not used in a , the codegen will /// not find the types, even with this attribute. ///
///
/// This attribute is properly inherited by subclasses. For example: ///
/// /// [SerializesGenericParameter(0)] /// public class MyClass<T> /// { /// } ///
/// public class MySubclass1 : MyClass<Foo> /// { /// } ///
/// public class MySubclass2<T> : MyClass<T> /// { /// } ///
/// [SerializesGenericParameter(1)] /// public class MySubclass3<TTypeOne, TTypeTwo> : MyClass<TTypeOne> /// { /// } ///
/// public class MyBehaviour : NetworkBehaviour /// { /// public MySubclass1 TheValue; /// public MySubclass2<Bar> TheValue; /// public MySubclass3<Baz, Qux> TheValue; /// } ///
///
/// The above code will trigger generation of serialization code for Foo (passed directly to the /// base class), Bar (passed indirectly to the base class), Baz (passed indirectly to the base class), /// and Qux (marked as serializable in the subclass). ///
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)] public class GenerateSerializationForGenericParameterAttribute : Attribute { internal int ParameterIndex; public GenerateSerializationForGenericParameterAttribute(int parameterIndex) { ParameterIndex = parameterIndex; } } }