EffectUI.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.CreateObj(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. PrefabManager.Instance.Restore(_gameObject);
  39. //GameObject.DestroyImmediate(_gameObject);
  40. _gameObject = null;
  41. }
  42. if (_wrapper != null)
  43. {
  44. if(_wrapper.wrapTarget != null)
  45. {
  46. _wrapper.wrapTarget = null;
  47. }
  48. _wrapper.Dispose();
  49. }
  50. }
  51. public GameObject GetObj()
  52. {
  53. return _gameObject;
  54. }
  55. }
  56. }