BindTypeNameToTypeAttribute class

Namespace: Sirenix.Serialization
Assembly: Sirenix.Serialization
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class BindTypeNameToTypeAttribute : Attribute, _Attribute
An attribute that lets you help the DefaultSerializationBinder bind type names to types. This is useful if you're renaming a type, that would result in data loss, and what to specify the new type name to avoid loss of data.
  • System.Object
  • System.Attribute
  • BindTypeNameToTypeAttribute
[assembly: OdinSerializer.BindTypeNameToType("Namespace.OldTypeName", typeof(Namespace.NewTypeName))]
//[assembly: OdinSerializer.BindTypeNameToType("Namespace.OldTypeName, OldFullAssemblyName", typeof(Namespace.NewTypeName))]

namespace Namespace
    public class SomeComponent : SerializedMonoBehaviour
        public IInterface test; // Contains an instance of OldTypeName;

    public interface IInterface { }

    public class NewTypeName : IInterface { }

    //public class OldTypeName : IInterface { }


BindTypeNameToTypeAttribute(String, Type)
Initializes a new instance of the BindTypeNameToTypeAttribute class.
public BindTypeNameToTypeAttribute(string oldFullTypeName, Type newType)
System.String oldFullTypeName

Old old full type name. If it's moved to new a new assembly you must specify the old assembly name as well. See example code in the documentation.

System.Type newType

The new type.

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.