EffectUI.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. if(_gameObject == null)
  26. {
  27. return;
  28. }
  29. _gameObject.transform.localScale = new Vector3(scale, scale, scale);
  30. _wrapper = new GoWrapper(_gameObject);
  31. holder.SetNativeObject(_wrapper);
  32. }
  33. public void Dispose()
  34. {
  35. isDisposed = true;
  36. if (_gameObject != null)
  37. {
  38. GameObject.DestroyImmediate(_gameObject);
  39. _gameObject = null;
  40. }
  41. if (_wrapper != null)
  42. {
  43. _wrapper.Dispose();
  44. }
  45. }
  46. }
  47. }