VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
override void AVR.Core.Attributes.DrawIfPropertyDrawer.OnGUI ( Rect  position,
SerializedProperty  property,
GUIContent  label 
)
inline

Definition at line 111 of file AVR_Attributes_PropertyDrawers.cs.

112  {
113  // Get attribute
114  ConditionalHideInInspector attr = attribute as ConditionalHideInInspector;
115 
116  // Get property that represents the hide condition
117  SerializedProperty prop = property.serializedObject.FindProperty(attr.hideConditionPropertyName);
118 
119  // Get its value
120  bool val = false;
121 
122  if(prop.type=="bool") {
123  val = prop.boolValue;
124  }
125  else if(prop.type=="float") {
126  val =
127  attr.ctype == ct.BIGGEREQUAL && prop.floatValue >= attr.compareValue ||
128  attr.ctype == ct.BIGGER && prop.floatValue > attr.compareValue ||
129  attr.ctype == ct.SMALLEREQUAL && prop.floatValue <= attr.compareValue ||
130  attr.ctype == ct.SMALLER && prop.floatValue < attr.compareValue ||
131  attr.ctype == ct.EQUAL && prop.floatValue == attr.compareValue ||
132  attr.ctype == ct.UNEQUAL && prop.floatValue != attr.compareValue;
133  }
134  else if (prop.type == "int") {
135  val =
136  attr.ctype == ct.BIGGEREQUAL && prop.intValue >= attr.compareValue ||
137  attr.ctype == ct.BIGGER && prop.intValue > attr.compareValue ||
138  attr.ctype == ct.SMALLEREQUAL && prop.intValue <= attr.compareValue ||
139  attr.ctype == ct.SMALLER && prop.intValue < attr.compareValue ||
140  attr.ctype == ct.EQUAL && prop.intValue == attr.compareValue ||
141  attr.ctype == ct.UNEQUAL && prop.intValue != attr.compareValue;
142  }
143  else if (prop.type == "double") {
144  val =
145  attr.ctype == ct.BIGGEREQUAL && prop.doubleValue >= attr.compareValue ||
146  attr.ctype == ct.BIGGER && prop.doubleValue > attr.compareValue ||
147  attr.ctype == ct.SMALLEREQUAL && prop.doubleValue <= attr.compareValue ||
148  attr.ctype == ct.SMALLER && prop.doubleValue < attr.compareValue ||
149  attr.ctype == ct.EQUAL && prop.doubleValue == attr.compareValue ||
150  attr.ctype == ct.UNEQUAL && prop.doubleValue != attr.compareValue;
151  }
152  else if (prop.type == "long") {
153  val =
154  attr.ctype == ct.BIGGEREQUAL && prop.longValue >= attr.compareValue ||
155  attr.ctype == ct.BIGGER && prop.longValue > attr.compareValue ||
156  attr.ctype == ct.SMALLEREQUAL && prop.longValue <= attr.compareValue ||
157  attr.ctype == ct.SMALLER && prop.longValue < attr.compareValue ||
158  attr.ctype == ct.EQUAL && prop.longValue == attr.compareValue ||
159  attr.ctype == ct.UNEQUAL && prop.longValue != attr.compareValue;
160  }
161  else if (prop.type == "Enum") {
162  val =
163  attr.ctype == ct.BIGGEREQUAL && prop.enumValueIndex >= attr.compareValue ||
164  attr.ctype == ct.BIGGER && prop.enumValueIndex > attr.compareValue ||
165  attr.ctype == ct.SMALLEREQUAL && prop.enumValueIndex <= attr.compareValue ||
166  attr.ctype == ct.SMALLER && prop.enumValueIndex < attr.compareValue ||
167  attr.ctype == ct.EQUAL && prop.enumValueIndex == attr.compareValue ||
168  attr.ctype == ct.UNEQUAL && prop.enumValueIndex != attr.compareValue;
169  }
170  else {
171  val = prop.objectReferenceValue != null;
172  }
173 
174  val ^= attr.invertCondition;
175 
176 
177  if (val)
178  {
179  // Dont draw
180  propertyHeight = 0f;
181  }
182  else
183  {
184  // draw
185  propertyHeight = base.GetPropertyHeight(property, label);
186  EditorGUI.PropertyField(position, property, new GUIContent(property.displayName));
187  }
188  }