Advertisement
squid808

CustomToggle

Nov 7th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. public bool CustomToggle(bool myToggle, int height, int width) {
  2.     string boxChecked;
  3.    
  4.     if (myToggle) {
  5.         boxChecked = "X";
  6.     } else {
  7.         boxChecked = "";
  8.     }
  9.    
  10.     if (GUILayout.Button(boxChecked, GUILayout.Height(height),
  11.         GUILayout.Width(width))) {
  12.        
  13.         myToggle = !myToggle;
  14.     }
  15.    
  16.     return myToggle;
  17. }
  18.  
  19. public override void OnInspectorGUI()
  20. {
  21.     EditorGUIUtility.LookLikeInspector();
  22.     EditorGUILayout.BeginVertical();
  23.  
  24.     for (int y = 0; y < Target.MaskHeight; y++)
  25.     {
  26.         EditorGUILayout.BeginHorizontal();
  27.         for (int x = 0; x < Target.MaskWidth; x++)
  28.         {
  29.             Target.Mask[x,y] = CustomToggle(Target.Mask[x, y], 16, 16);
  30.         }
  31.         EditorGUILayout.EndHorizontal();
  32.     }
  33.  
  34.     EditorGUILayout.EndVertical();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement