public void OnChangeDecimalInput()
        {
            if (SavingNew)
            {
                return;
            }

            if (mSuspendUpdates)
            {
                return;
            }

            if (SelectedObject != null)
            {
                mSuspendUpdates = true;

                Debug.Log("Changed decimal input");

                Single.TryParse(DecimalInput.text, out CurrentDecimalValue);
                //get the range and make sure it's clamped
                var atts = SelectedObject.GetCustomAttributes(typeof(EditableDifficultySettingAttribute), true);
                EditableDifficultySettingAttribute dsa = null;
                foreach (var att in atts)
                {
                    dsa = (EditableDifficultySettingAttribute)att;
                    if (dsa != null)
                    {
                        break;
                    }
                }
                //this is tricky because we need a decimal point if it was added
                CurrentDecimalValue     = Mathf.Clamp(CurrentDecimalValue, dsa.MinRangeFloat, dsa.MaxRangeFloat);
                DecimalInput.text       = CurrentDecimalValue.ToString();
                DecimalInput.label.text = DecimalInput.text;
                //SelectedObject.SetValue(null, CurrentDecmalValue);
                ApplyChangesButton.SendMessage("SetEnabled");
                mSuspendUpdates = false;
            }
        }
        public void OnChangeIntegerInput()
        {
            if (SavingNew)
            {
                return;
            }

            if (mSuspendUpdates)
            {
                return;
            }

            if (SelectedObject != null)
            {
                mSuspendUpdates = true;

                Debug.Log("Changed integer input");
                int newValue = 0;
                Int32.TryParse(IntegerInput.text, out newValue);
                var atts = SelectedObject.GetCustomAttributes(typeof(EditableDifficultySettingAttribute), true);
                EditableDifficultySettingAttribute dsa = null;
                foreach (var att in atts)
                {
                    dsa = (EditableDifficultySettingAttribute)att;
                    if (dsa != null)
                    {
                        break;
                    }
                }
                newValue                = Mathf.Clamp(newValue, dsa.MinRangeInt, dsa.MaxRangeInt);
                IntegerInput.text       = newValue.ToString();
                IntegerInput.label.text = IntegerInput.text;
                //SelectedObject.SetValue(null, newValue);
                ApplyChangesButton.SendMessage("SetEnabled");
                mSuspendUpdates = false;
            }
        }
        public override void PushSelectedObjectToViewer()
        {
            if (SavingNew)
            {
                return;
            }

            mSuspendUpdates = true;

            var atts = SelectedObject.GetCustomAttributes(typeof(EditableDifficultySettingAttribute), true);
            EditableDifficultySettingAttribute dsa = null;

            foreach (var att in atts)
            {
                dsa = (EditableDifficultySettingAttribute)att;
                if (dsa != null)
                {
                    break;
                }
            }

            if (dsa == null)
            {
                GlobalVariableNameLabel.text = "Unknown / Not a difficulty setting";
                GlobalVariableTypeLabel.text = "Unknown";
                GlobalVariableDescLabel.text = "This type is unknown and/or uneditable";
                return;
            }

            DifficultySettingGlobal dsg = null;

            for (int i = 0; i < CurrentDifficultySetting.GlobalVariables.Count; i++)
            {
                if (CurrentDifficultySetting.GlobalVariables[i].GlobalVariableName == SelectedObject.Name)
                {
                    dsg = CurrentDifficultySetting.GlobalVariables[i];
                    break;
                }
            }

            GlobalVariableNameLabel.text = SelectedObject.Name;
            GlobalVariableDescLabel.text = dsa.Description;

            switch (dsa.Type)
            {
            case EditableDifficultySettingAttribute.SettingType.Bool:
                GlobalVariableTypeLabel.text = "Type: True/False";
                CurrentToggleValue           = (bool)SelectedObject.GetValue(null);
                if (dsg != null)
                {
                    Boolean.TryParse(dsg.VariableValue, out CurrentToggleValue);
                }
                BooleanInput.isChecked = CurrentToggleValue;
                BooleanInput.gameObject.SetActive(true);
                IntegerInput.gameObject.SetActive(false);
                DecimalInput.gameObject.SetActive(false);
                break;

            case EditableDifficultySettingAttribute.SettingType.FloatRange:
                GlobalVariableTypeLabel.text = "Type: Decimal Range (" + dsa.MinRangeFloat.ToString("0.0#####") + " - " + dsa.MaxRangeFloat.ToString("0.0#####") + ")";
                CurrentDecimalValue          = (float)SelectedObject.GetValue(null);
                if (dsg != null)
                {
                    Single.TryParse(dsg.VariableValue, out CurrentDecimalValue);
                }
                DecimalInput.text       = CurrentDecimalValue.ToString("0.0#####");
                DecimalInput.label.text = DecimalInput.text;
                DecimalInput.gameObject.SetActive(true);
                UIInput.current = DecimalInput;
                IntegerInput.gameObject.SetActive(false);
                BooleanInput.gameObject.SetActive(false);
                break;

            case EditableDifficultySettingAttribute.SettingType.IntRange:
                GlobalVariableTypeLabel.text = "Type: Integer Range (" + dsa.MinRangeInt.ToString() + " - " + dsa.MaxRangeInt.ToString() + ")";
                CurrentIntegerValue          = (int)SelectedObject.GetValue(null);
                if (dsg != null)
                {
                    Int32.TryParse(dsg.VariableValue, out CurrentIntegerValue);
                }
                IntegerInput.text       = CurrentIntegerValue.ToString();
                IntegerInput.label.text = IntegerInput.text;
                UIInput.current         = IntegerInput;
                IntegerInput.gameObject.SetActive(true);
                DecimalInput.gameObject.SetActive(false);
                BooleanInput.gameObject.SetActive(false);
                break;

            case EditableDifficultySettingAttribute.SettingType.String:
                //StringInput.gameObject.SetActive(true);
                break;

            case EditableDifficultySettingAttribute.SettingType.Hidden:
            default:
                IntegerInput.gameObject.SetActive(false);
                DecimalInput.gameObject.SetActive(false);
                BooleanInput.gameObject.SetActive(false);
                GlobalVariableTypeLabel.text = "(Hidden)";
                GlobalVariableDescLabel.text = "This type is unknown and/or uneditable";
                break;
            }

            ApplyChangesButton.gameObject.SetActive(true);
            ApplyChangesButton.SendMessage("SetDisabled");
            RemoveSettingButton.gameObject.SetActive(true);

            mSuspendUpdates = false;
        }
        public void OnClickApplySettingButton()
        {
            if (mSuspendUpdates)
            {
                return;
            }

            mSuspendUpdates = true;

            bool createdNewSetting = false;

            var atts = SelectedObject.GetCustomAttributes(typeof(EditableDifficultySettingAttribute), true);
            EditableDifficultySettingAttribute dsa = null;

            foreach (var att in atts)
            {
                dsa = (EditableDifficultySettingAttribute)att;
                if (dsa != null)
                {
                    break;
                }
            }

            DifficultySettingGlobal dsg = null;

            for (int i = 0; i < CurrentDifficultySetting.GlobalVariables.Count; i++)
            {
                if (CurrentDifficultySetting.GlobalVariables[i].GlobalVariableName == SelectedObject.Name)
                {
                    dsg = CurrentDifficultySetting.GlobalVariables[i];
                    break;
                }
            }

            if (dsg == null)
            {
                dsg = new DifficultySettingGlobal();
                dsg.GlobalVariableName = SelectedObject.Name;
                CurrentDifficultySetting.GlobalVariables.Add(dsg);
                createdNewSetting = true;
            }

            switch (dsa.Type)
            {
            case EditableDifficultySettingAttribute.SettingType.Bool:
                dsg.VariableValue = CurrentToggleValue.ToString();
                //SelectedObject.SetValue(null, CurrentToggleValue);
                break;

            case EditableDifficultySettingAttribute.SettingType.FloatRange:
                dsg.VariableValue = CurrentDecimalValue.ToString();
                //SelectedObject.SetValue(null, CurrentDecimalValue);
                break;

            case EditableDifficultySettingAttribute.SettingType.IntRange:
                dsg.VariableValue = CurrentIntegerValue.ToString();
                //SelectedObject.SetValue(null, CurrentIntegerValue);
                break;

            case EditableDifficultySettingAttribute.SettingType.String:
                //StringInput.gameObject.SetActive(true);
                break;

            case EditableDifficultySettingAttribute.SettingType.Hidden:
            default:
                break;
            }

            ApplyChangesButton.SendMessage("SetDisabled");

            mSuspendUpdates = false;

            CurrentDifficultySetting.HasBeenCustomized = true;

            if (createdNewSetting)
            {
                ReceiveFromParentEditor(FetchItems());
                ResetInputs();
            }
            else
            {
                ResetInputs();
            }
        }