void LoadProfile()
    {
        if (!CheckPlaying())
        {
            return;
        }

        string prevProfile = MadLevelProfile.profile;

        MadLevelProfile.profile = selectedProfileName;

        var path = EditorUtility.OpenFilePanel("Load Profile", "", "profile");

        if (path.Length != 0)
        {
            var levels = System.IO.File.ReadAllText(path);
            MadLevelProfile.LoadProfileFromString(levels);
            MadLevelProfile.Save();

            // reload level
            MadLevel.ReloadCurrent();
        }

        MadLevelProfile.profile = prevProfile;
    }
    void SwitchProfile(string profile)
    {
        if (!CheckPlaying())
        {
            return;
        }

        MadLevelProfile.profile = profile;
        MadLevel.ReloadCurrent();
    }
 void Update()
 {
     if (resetOnRKey)
     {
         if (Input.GetKey(KeyCode.R))
         {
             MadLevelProfile.Reset();
             MadLevel.ReloadCurrent();
         }
     }
 }
    void CompleteAllLevels()
    {
        if (!CheckPlaying())
        {
            return;
        }

        var levelNames = MadLevel.GetAllLevelNames();

        foreach (var levelName in levelNames)
        {
            MadLevelProfile.SetCompleted(levelName, true);
        }

        MadLevel.ReloadCurrent();
    }
    void UnlockAllLevels()
    {
        if (!CheckPlaying())
        {
            return;
        }

        var levelNames = MadLevel.GetAllLevelNames();

        foreach (var levelName in levelNames)
        {
            MadLevelProfile.SetLocked(levelName, false);
        }

        MadLevel.ReloadCurrent();
    }
    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    void Start()
    {
        var sprite = GetComponent <MadSprite>();

        if (sprite != null)
        {
            sprite.onMouseEnter += (s) =>
                                   sprite.AnimScaleTo(Vector3.one * 1.5f, 1, MadiTween.EaseType.easeOutElastic);
            sprite.onMouseExit += (s) =>
                                  sprite.AnimScaleTo(Vector3.one, 1, MadiTween.EaseType.easeOutElastic);
            sprite.onMouseDown += sprite.onTap = (s) => {
                MadLevelProfile.Reset();
                MadLevel.ReloadCurrent();
            };
        }
    }
    void ResetProfile(string profile)
    {
        if (!CheckPlaying())
        {
            return;
        }

        if (EditorUtility.DisplayDialog(
                "Reset Profile " + profile + "?",
                "Are you sure you want to reset profile '" + profile + "'? This cannot be undone.",
                "Yes", "No"))
        {
            string prevProfile = MadLevelProfile.profile;
            MadLevelProfile.profile = selectedProfileName;
            MadLevelProfile.Reset();
            MadLevelProfile.profile = prevProfile;

            MadLevel.ReloadCurrent();
        }
    }