No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LoadFromResource.cs 967B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.U2D;
  5. public class LoadFromResource : MonoBehaviour
  6. {
  7. void OnEnable()
  8. {
  9. SpriteAtlasManager.atlasRequested += RequestLateBindingAtlas;
  10. SpriteAtlasManager.atlasRegistered += AtlasRegistered;
  11. }
  12. void OnDisable()
  13. {
  14. SpriteAtlasManager.atlasRequested -= RequestLateBindingAtlas;
  15. SpriteAtlasManager.atlasRegistered -= AtlasRegistered;
  16. }
  17. void RequestLateBindingAtlas(string tag, System.Action<SpriteAtlas> callback)
  18. {
  19. if (tag == "ResourceAtlas1")
  20. {
  21. var sa = UnityEngine.Resources.Load<SpriteAtlas>("ResourceAtlas1");
  22. callback(sa);
  23. }
  24. else
  25. Debug.Log("Error: Late binding callback with wrong atlas tag of " + tag);
  26. }
  27. void AtlasRegistered(SpriteAtlas spriteAtlas)
  28. {
  29. Debug.LogFormat("Registered {0}.", spriteAtlas.name);
  30. }
  31. }