JUtils
A unity utilities library
JUtils.ShowWhenAttribute Class Reference

Hide a field if the condition does not match, allows checks for bools, ints, floats & strings More...

Inheritance diagram for JUtils.ShowWhenAttribute:
Collaboration diagram for JUtils.ShowWhenAttribute:

Public Types

enum class  Comparer { Equals , Or , Greater , Smaller }
 

Public Member Functions

 ShowWhenAttribute (string variable, string value, bool showAsObject=true)
 Shows when the "Variable" field does not match the "value" More...
 
 ShowWhenAttribute (string variable, int value, Comparer comparer=Comparer.Equals)
 Shows when the "Variable" field does not match the "value" More...
 
 ShowWhenAttribute (string variable, int value, bool showAsObject, Comparer comparer=Comparer.Equals)
 Shows when the "Variable" field returns true on tne comparer More...
 
 ShowWhenAttribute (string variable, float value, Comparer comparer=Comparer.Equals)
 Shows when the "Variable" field returns true on tne comparer More...
 
 ShowWhenAttribute (string variable, float value, bool showAsObject, Comparer comparer=Comparer.Equals)
 Shows when the "Variable" field returns true on tne comparer More...
 
 ShowWhenAttribute (string variable, bool value, bool showAsObject=true)
 Shows when the "Variable" field matches the bool value More...
 

Public Attributes

readonly string variable
 
readonly object value
 
readonly Comparer comparer
 
readonly bool showAsObject
 

Detailed Description

Hide a field if the condition does not match, allows checks for bools, ints, floats & strings

namespace Example
{
public class ShowWhenExample : MonoBehaviour
{
[SerializeField] private bool _autoSet;
[ShowWhen(nameof(_autoSet), false)]
[SerializeField, Required] private Settings _settings;
}
}

Member Enumeration Documentation

◆ Comparer

Enumerator
Equals 
Or 
Greater 
Smaller 

Constructor & Destructor Documentation

◆ ShowWhenAttribute() [1/6]

JUtils.ShowWhenAttribute.ShowWhenAttribute ( string  variable,
string  value,
bool  showAsObject = true 
)
inline

Shows when the "Variable" field does not match the "value"

References JUtils.ShowWhenAttribute.showAsObject, JUtils.ShowWhenAttribute.value, and JUtils.ShowWhenAttribute.variable.

◆ ShowWhenAttribute() [2/6]

JUtils.ShowWhenAttribute.ShowWhenAttribute ( string  variable,
int  value,
Comparer  comparer = Comparer.Equals 
)
inline

◆ ShowWhenAttribute() [3/6]

JUtils.ShowWhenAttribute.ShowWhenAttribute ( string  variable,
int  value,
bool  showAsObject,
Comparer  comparer = Comparer.Equals 
)
inline

◆ ShowWhenAttribute() [4/6]

JUtils.ShowWhenAttribute.ShowWhenAttribute ( string  variable,
float  value,
Comparer  comparer = Comparer.Equals 
)
inline

◆ ShowWhenAttribute() [5/6]

JUtils.ShowWhenAttribute.ShowWhenAttribute ( string  variable,
float  value,
bool  showAsObject,
Comparer  comparer = Comparer.Equals 
)
inline

◆ ShowWhenAttribute() [6/6]

JUtils.ShowWhenAttribute.ShowWhenAttribute ( string  variable,
bool  value,
bool  showAsObject = true 
)
inline

Shows when the "Variable" field matches the bool value

References JUtils.ShowWhenAttribute.showAsObject, JUtils.ShowWhenAttribute.value, and JUtils.ShowWhenAttribute.variable.

Member Data Documentation

◆ comparer

readonly Comparer JUtils.ShowWhenAttribute.comparer

◆ showAsObject

readonly bool JUtils.ShowWhenAttribute.showAsObject

◆ value

readonly object JUtils.ShowWhenAttribute.value

◆ variable

readonly string JUtils.ShowWhenAttribute.variable

The documentation for this class was generated from the following file: