EffectUI.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using FairyGUI;
  2. using UnityEngine;
  3. namespace GFGGame
  4. {
  5. public class EffectUI
  6. {
  7. private GameObject _gameObject;
  8. private GoWrapper _wrapper;
  9. public bool isDisposed;
  10. public void Reset(GGraph holder, string uiName, string resName, float scale = 100, EffectUIType effectUIType = EffectUIType.UI )
  11. {
  12. if (!isDisposed) Dispose();
  13. isDisposed = false;
  14. string resPath;
  15. switch(effectUIType)
  16. {
  17. case EffectUIType.Card:
  18. resPath = ResPathUtil.GetCardAnimationPath(resName);
  19. break;
  20. default:
  21. resPath = ResPathUtil.GetViewEffectPath(uiName, resName);
  22. break;
  23. }
  24. _gameObject = DressUpUtil.CreateAnimationObj(resPath);
  25. _gameObject.transform.localScale = new Vector3(scale, scale, scale);
  26. _wrapper = new GoWrapper(_gameObject);
  27. holder.SetNativeObject(_wrapper);
  28. }
  29. public void Dispose()
  30. {
  31. isDisposed = true;
  32. if (_gameObject != null)
  33. {
  34. GameObject.DestroyImmediate(_gameObject);
  35. _gameObject = null;
  36. }
  37. if (_wrapper != null)
  38. {
  39. _wrapper.Dispose();
  40. }
  41. }
  42. }
  43. }