Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

InstancePolicyAttribute

A topic by CatyboyStudio created Oct 15, 2022 Views: 90
Viewing posts 1 to 1
(1 edit)

Define how to handle the instantiation policy of the following situations

  • the none-serializable property
  • property mark with [SerializeReference]


public interface INestClass         
{
}
public class NestClass1 : INestClass
{
    public int Value;
}
[ShowInInspector]
[InstancePolicy(InstancePolicyAttribute.PolicyType.Nullable)]
public NestClass1 NC;
[SerializeReference]         
[InstancePolicy(InstancePolicyAttribute.PolicyType.UsingDerived)]         
public INestClass NestInterface;

PolicyType

  • Default: instantiating the object directly
  • Nullable: null values are allowed, and instantiation can be selected by clicking the button
  • UsingDerived: null values are allowed, and the type of instantiation can be selected by clicking the button