123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using FairyGUI;
- using UnityEngine;
- namespace GFGGame
- {
- public class EffectUI
- {
- private GameObject _gameObject;
- private GoWrapper _wrapper;
- public bool Released;
- public void Reset(GGraph holder, string uiName, string resName, float scale = 100, EffectUIType effectUIType = EffectUIType.UI )
- {
- if (!Released) Release();
- Released = false;
- string resPath;
- switch(effectUIType)
- {
- case EffectUIType.Card:
- resPath = ResPathUtil.GetCardAnimationPath(resName);
- break;
- default:
- resPath = ResPathUtil.GetViewEffectPath(uiName, resName);
- break;
- }
- _gameObject = PrefabManager.Instance.SpawnSync(resPath);
- if(_gameObject == null)
- {
- return;
- }
- _gameObject.transform.localScale = new Vector3(scale, scale, scale);
- _wrapper = new GoWrapper(_gameObject);
- holder.SetNativeObject(_wrapper);
- }
- public void Release()
- {
- Released = true;
- if (_gameObject != null)
- {
- PrefabManager.Instance.Restore(_gameObject);
- //GameObject.DestroyImmediate(_gameObject);
- _gameObject = null;
- }
- if (_wrapper != null)
- {
- if(_wrapper.wrapTarget != null)
- {
- _wrapper.wrapTarget = null;
- }
- _wrapper.Dispose();
- _wrapper = null;
- }
- }
- public GameObject GetObj()
- {
- return _gameObject;
- }
- }
- }
|