예제 #1
0
    private void OnTagChange()
    {
        // Unfocus field so the value doesn't get displayed in the new tag.
        GUI.FocusControl("");
        // Delete any temporary objects which may have been created when loading the previous tag.
        DestroyTemporaryObjects();

        if (currentIndex >= 0)
        {
            currentTag = tags[currentIndex];
            ES2Settings settings = new ES2Settings();
            settings.tag = currentTag;
            settings.encryptionPassword = this.encryptionPassword;

            try
            {
                currentValue = ES2.LoadObject(currentFilePath, settings);
                currentTagRequiresPassword = false;
            }
            catch (System.Security.Cryptography.CryptographicException e)
            {
                e.Message.GetType();                 // Suppress warning that e is not being used.

                // If there's a cryptography exception, we require a password.
                // Flag that we need to request a password when we display the GUI.
                currentTagRequiresPassword = true;
            }
            catch (Exception e)
            {
                EditorUtility.DisplayDialog("Could not load tag", "This tag could not be loaded. Please ensure that the tag was added to the file using Easy Save.\nFailed with exception:\n" + e.ToString(), "Ok");
            }
        }
        else
        {
            currentTag   = null;
            currentValue = null;
        }
        currentArrayFoldouts = null;
    }