TestEditor.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Security.Cryptography;
  2. using System.Text;
  3. namespace AtlasUtility
  4. {
  5. using LitJson;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Collections.Generic;
  9. using UnityEditor;
  10. using UnityEngine;
  11. using UnityEngine.UI;
  12. using UnityEditor.iOS.Xcode;
  13. [CustomEditor(typeof(Test))]
  14. public class TestEditor : Editor
  15. {
  16. #region Variable
  17. public Test Script;
  18. #endregion
  19. public void OnEnable()
  20. {
  21. Script = (Test) target;
  22. }
  23. public override void OnInspectorGUI()
  24. {
  25. base.OnInspectorGUI();
  26. if (GUILayout.Button("Test"))
  27. {
  28. MD5 md5 = new MD5CryptoServiceProvider();
  29. byte[] bytes1 = File.ReadAllBytes(@"C:\Users\Administrator\Desktop\MD5测试1.txt");
  30. byte[] md5Bytes1 = md5.ComputeHash(bytes1);
  31. byte[] bytes2 = File.ReadAllBytes(@"C:\Users\Administrator\Desktop\MD5测试2.txt");
  32. byte[] md5Bytes2 = md5.ComputeHash(bytes2);
  33. if (md5Bytes1.Length != md5Bytes2.Length)
  34. {
  35. Debug.Log("false");
  36. return;
  37. }
  38. else
  39. {
  40. for (int i = 0; i < md5Bytes1.Length; i++)
  41. {
  42. if (md5Bytes1[i] != md5Bytes2[i])
  43. {
  44. Debug.Log("false");
  45. return;
  46. }
  47. }
  48. Debug.Log("true");
  49. }
  50. }
  51. }
  52. }
  53. }