BuildAssetBundle.cs 680 B

123456789101112131415161718192021222324
  1. using System.IO;
  2. using UnityEditor;
  3. namespace Unity.U2D.Animation.Sample
  4. {
  5. // ensure class initializer is called whenever scripts recompile
  6. [InitializeOnLoadAttribute]
  7. internal static class BuildAssetBundle
  8. {
  9. // register an event handler when the class is initialized
  10. static BuildAssetBundle()
  11. {
  12. EditorApplication.playModeStateChanged += PlayModeStateChange;
  13. }
  14. private static void PlayModeStateChange(PlayModeStateChange state)
  15. {
  16. if (state == UnityEditor.PlayModeStateChange.ExitingEditMode)
  17. {
  18. LoadSwapDLC.BuildAssetBundles();
  19. }
  20. }
  21. }
  22. }