void EditDomainAsset(Object testAsset, StringCryptographer decrypter, out string testResult, out MessageType testResultType) { // Setup variables AssetBundle bundle = null; testResult = TestErrorInvalidFileMessage; testResultType = MessageType.Error; // Null check if (testAsset == null) { // Don't do anything if asset is null return; } try { // Check if we can get the path of the asset string localAssetPath = AssetDatabase.GetAssetPath(testAsset); // Load the bundle, and convert it to a domain list bundle = AssetBundle.LoadFromFile(localAssetPath); DomainList domainList = Utility.GetDomainList(bundle); // By default, indicate the bundle doesn't contain DomainList testResult = TestErrorInvalidAssetMessage; testResultType = MessageType.Error; // Check if the bundle contains an AcceptedDomainList if (domainList != null) { // By default, indicate the domain list is empty testResult = TestEmptyWarningMessage; testResultType = MessageType.Warning; if ((domainList != null) && (domainList.Count > 0)) { // Replace the name of file nameOfFile = Path.GetFileName(localAssetPath); // Replace the name of folder int stringLengthOfFolder = (localAssetPath.Length - (nameOfFile.Length + 1)); nameOfFolder = localAssetPath.Substring(0, stringLengthOfFolder); // Replace the domain list DomainList.Decrypt(domainList, decrypter, allDomains); testResult = EditMessage; testResultType = MessageType.Info; } } } finally { if (bundle != null) { // Clean-up bundle.Unload(true); } } }
static string[] ConvertToDomainList(DomainList domainList, StringCryptographer decrypter) { string[] returnDomainList = null; if ((domainList != null) && (domainList.Count > 0)) { // Create a new string array returnDomainList = DomainList.Decrypt(domainList, decrypter); } return(returnDomainList); }
private void DrawArchiveContents() { EditorUiUtility.DrawBoldFoldout(contentAnimation, "Archive Contents"); // Draw the rest of the controls using (EditorGUILayout.FadeGroupScope fadeScope = new EditorGUILayout.FadeGroupScope(contentAnimation.faded)) { if (fadeScope.visible == true) { // Draw the rest of the controls EditorGUILayout.PropertyField(includeIndexHtml); EditorGUILayout.PropertyField(domainEncrypter); domainList.DoLayoutList(); // Draw the import stuff EditorGUILayout.Space(); UnityEngine.Object testAsset = null; testAsset = EditorGUILayout.ObjectField("Import Domain List", testAsset, typeof(UnityEngine.Object), false); if (testAsset != null) { AssetBundle bundle = null; try { // Load the bundle, and convert it to a domain list bundle = AssetBundle.LoadFromFile(AssetDatabase.GetAssetPath(testAsset)); DomainList domainList = Utility.GetDomainList(bundle); // Decrypt the domain list HostArchiveSetting setting = ((HostArchiveSetting)target); setting.AcceptedDomains = DomainList.Decrypt(domainList, setting.DomainEncrypter); } finally { if (bundle != null) { // Clean-up bundle.Unload(true); } } } } } }