Skip to content

A property attribute to make comparisions on editor before displaying a value

License

Notifications You must be signed in to change notification settings

alvmivan/showif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Show If

A property attribute to make comparisions on editor before displaying a value

The [ShowIf] attribute will allow you to hide or show a serialized attribute when needed

It can be used for checking a sibling boolean field

public bool useReferencedPrefab;
[ShowIf("useReferencedPrefab")]
public GameObject prefab;

Also the boolean condition can be inverted to get a "show if not"

[ShowIf("useReferencedPrefab",invert:true)]
public string resourcesPath;

Also by using the comparers

public WeaponShootingType shootingType;
[ShowIf("shootingType","==",WeaponShootingType.PhysicProjectile)]
public ProjectileConfig projectileConfig;
[ShowIf("shootingType","==",WeaponShootingType.Raycast)]
public RaycastConfig raycastConfig;

You can compare with a number too

public float spreading;
[ShowIf("spreading",">",0)]
public SpreadSettings spreadSettings;

NOTE: allowed comparers are:

"==", "!=", ">", ">=", "<", "<="

About

A property attribute to make comparisions on editor before displaying a value

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages