AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ShowIfBoolValueAttribute.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using System;
5 #if UNITY_EDITOR
6 using UnityEditor;
7 #endif
8 
9 namespace HoloToolkit.Unity
10 {
11  // Shows / hides based on bool value of named member
12  [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
14  {
15 
16  public ShowIfBoolValueAttribute(string boolMemberName, bool showIfConditionMet = true)
17  {
18  MemberName = boolMemberName;
19  ShowIfConditionMet = showIfConditionMet;
20  }
21 
22 #if UNITY_EDITOR
23  public override bool ShouldShow(object target)
24  {
25  bool conditionMet = (bool)GetMemberValue(target, MemberName);
26  return ShowIfConditionMet ? conditionMet : !conditionMet;
27  }
28 #endif
29  }
30 }
ShowIfBoolValueAttribute(string boolMemberName, bool showIfConditionMet=true)