EffectUI.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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)
  11. {
  12. if (!isDisposed) Dispose();
  13. isDisposed = false;
  14. string resPath = ResPathUtil.GetViewEffectPath(uiName, resName);
  15. _gameObject = DressUpUtil.CreateAnimationObj(resPath);
  16. _gameObject.transform.localScale = new Vector3(scale, scale, scale);
  17. _wrapper = new GoWrapper(_gameObject);
  18. holder.SetNativeObject(_wrapper);
  19. }
  20. public void Dispose()
  21. {
  22. isDisposed = true;
  23. if (_gameObject != null)
  24. {
  25. GameObject.DestroyImmediate(_gameObject);
  26. _gameObject = null;
  27. }
  28. if (_wrapper != null)
  29. {
  30. _wrapper.Dispose();
  31. }
  32. }
  33. }
  34. }