83 lines
2.1 KiB
C#
83 lines
2.1 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2022-03-08
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "PetSpineWidget" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
namespace G
|
|
{
|
|
/// <summary>
|
|
/// 宠物
|
|
/// </summary>
|
|
public class PetSpineWidget : KUIWidget
|
|
{
|
|
#region Field
|
|
|
|
string _lastChaAsset;
|
|
AsyncOperationHandle<GameObject> _chaHandle;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="chaSkinAsset"></param>
|
|
/// <param name="weaponSkinAsset"></param>
|
|
/// <param name="callback"></param>
|
|
public void Show(string chaSkinAsset, Callback2 callback)
|
|
{
|
|
StartCoroutine(ShowSkinCO(chaSkinAsset, callback));
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="kind"></param>
|
|
/// <param name="assets"></param>
|
|
/// <returns></returns>
|
|
private IEnumerator ShowSkinCO(string chaAsset, Callback2 callback)
|
|
{
|
|
if (!_chaHandle.IsValid() || _chaHandle.Result.name != chaAsset)
|
|
{
|
|
if (_chaHandle.IsValid())
|
|
{
|
|
AssetProxy.Instance.ReleaseInstance(_chaHandle);
|
|
}
|
|
|
|
_chaHandle = AssetProxy.Instance.InstantiateAsync(chaAsset, this.transform);
|
|
yield return _chaHandle;
|
|
_chaHandle.Result.name = chaAsset;
|
|
}
|
|
|
|
callback?.Invoke(0, "");
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Unity
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private void Awake()
|
|
{
|
|
SetViewData();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|