Beispiel #1
0
 public static void SafeInit(this IconBase icon)
 {
     try {
         icon.Init();
     } catch (Exception e) {
         Debug.LogException(e);
         Preferences.ForceDisableButton(icon);
     }
 }
Beispiel #2
0
 public static void SafeDoGUI(this IconBase icon, Rect rect)
 {
     try {
         icon.DoGUI(rect);
     } catch (Exception e) {
         Debug.LogException(e);
         Preferences.ForceDisableButton(icon);
     }
 }
Beispiel #3
0
 public static string SafeGetName(this IconBase icon)
 {
     try {
         return(icon.Name);
     } catch (Exception e) {
         Debug.LogException(e);
         Preferences.ForceDisableButton(icon);
         return(string.Empty);
     }
 }
Beispiel #4
0
 public static float SafeGetWidth(this IconBase icon)
 {
     try {
         return(icon.Width);
     } catch (Exception e) {
         Debug.LogException(e);
         Preferences.ForceDisableButton(icon);
         return(0f);
     }
 }
 public static void SafeDoGUI(this IconBase icon, Rect rect)
 {
     try {
         rect.yMin -= (Preferences.IconsSize - 15) / 2;
         rect.xMin -= (Preferences.IconsSize - 15) / 2;
         icon.DoGUI(rect);
     } catch (Exception e) {
         Debug.LogException(e);
         Preferences.ForceDisableButton(icon);
     }
 }
Beispiel #6
0
        public static bool IsButtonEnabled(IconBase button)
        {
            if (button == null)
            {
                return(false);
            }

            if (LeftSideButton == button)
            {
                return(true);
            }

            return(RightIcons.Value.Contains(button) || LeftIcons.Value.Contains(button));
        }
 public void OnAfterDeserialize()
 {
     if (isLeftSide)
     {
         icon = (LeftSideIcon)name;
     }
     else if (isRightSide)
     {
         icon = (RightSideIcon)name;
     }
     else
     {
         icon = null;
     }
     //    throw new ArgumentException("Data isn't a right side nor left side icon");
 }
Beispiel #8
0
        public static void ForceDisableButton(IconBase button)
        {
            Debug.LogWarning("Disabling \"" + button.Name + "\", most likely because it threw an exception");

            if (LeftSideButton.Value == button)
            {
                LeftSideButton.Value = new Icons.RightNone();
            }
            else if (button is RightSideIcon)
            {
                RightIcons.Value = (from icon in RightIcons.Value
                                    where icon != button
                                    select icon).ToArray();
            }
            else
            {
                LeftIcons.Value = (from icon in LeftIcons.Value
                                   where icon != button
                                   select icon).ToArray();
            }
        }
Beispiel #9
0
        public static bool IsButtonEnabled(IconBase button)
        {
            if (button == null)
            {
                return(false);
            }

            if (LeftSideButton.Value == button)
            {
                return(true);
            }

            if (button is RightSideIcon)
            {
                return(RightIcons.Value.Contains((RightSideIcon)button));
            }
            else
            {
                return(LeftIcons.Value.Contains((LeftSideIcon)button));
            }
        }
Beispiel #10
0
        public static void ForceDisableButton(IconBase button)
        {
            if (button == null)
            {
                Debug.LogError("Removing null button");
            }
            else
            {
                Debug.LogWarning("Disabling \"" + button.Name + "\", most likely because it threw an exception");
            }

            if (LeftSideButton == button)
            {
                LeftSideButton = IconBase.none;
            }

            RightIcons.Value.Remove(button);
            LeftIcons.Value.Remove(button);

            RightIcons.ForceSave();
            LeftIcons.ForceSave();
        }
 public void OnAfterDeserialize()
 {
     Icon = name;
 }