using game; using UnityEngine; public class SkinItemPreviewer : BaseItemPreviewer { private ConfSkinShopItem _itemConf; private GameObject _previewObject; public override void ChangeItem(ConfBaseShopItem conf, bool needShade) { _itemConf = conf as ConfSkinShopItem; Error.Verify(_itemConf != null, "SkinShopItemPreviewer: invalid type for item config " + conf.GetType()); TryDestroyLastPreview(); _previewObject = CreatePreview(); if(needShade) ShadeObject(_previewObject); } public override void Show(bool skipAnimation = true) { if(_previewObject == null) return; _previewObject.SetActive(true); } public override void Hide(bool skipAnimation = true) { if(_previewObject == null) return; _previewObject.SetActive(false); } private void TryDestroyLastPreview() { if (_previewObject != null) Destroy(_previewObject); } private GameObject CreatePreview() { GameObject obj = Assets.Create(_itemConf.previewPath); obj.SetParent(transform); obj.transform.localPosition = Vector3.zero; return obj; } }