Beispiel #1
0
    void UpdateSaveButton()
    {
        if ((isUnsavedNewCard && !hasCardChanges && !codeEditor.HasUnsavedChanges()) ||
            card.GetUnassignedBehaviorItem().IsBehaviorReadOnly())
        {
            saveButton.gameObject.SetActive(false);
            return;
        }

        saveButton.gameObject.SetActive(true);
        var saveUtil = new ButtonUtil()
        {
            button      = saveButton,
            buttonImage = saveButtonImage,
            label       = saveButtonText,
            controller  = this
        };

        if (isUnsavedNewCard)
        {
            saveUtil.Enable("SAVE NEW (CTRL-S)");
        }
        else
        {
            // We're really kinda overloading the meaning of this button, but oh well.
            if (codeEditor.HasUnsavedChanges())
            {
                saveUtil.Enable("SAVE & RUN (CTRL-S)");

                // Flash...
                saveButtonText.color = Util.BoolWave(Time.unscaledTime, 0.35f) ? Color.Lerp(buttonTextColor, Color.clear, .4f) : buttonTextColor;
            }
            else if (hasCardChanges)
            {
                saveUtil.Enable("SAVE (CTRL-S)");
            }
            else
            {
                saveUtil.Disable("(No changes)");
            }
        }
    }