Version 3.3.0.1

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.
Inheritance
  • System.Object
  • System.Attribute
  • BindTypeNameToTypeAttribute
Example
[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 { }
}

Constructors

BindTypeNameToTypeAttribute(String, Type)
Initializes a new instance of the BindTypeNameToTypeAttribute class.
public BindTypeNameToTypeAttribute(string oldFullTypeName, Type newType)
Parameters
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.