80 lines
2.4 KiB
C#
80 lines
2.4 KiB
C#
|
|
|||
|
using Cal.DataTable;
|
|||
|
using ET;
|
|||
|
using FairyGUI;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class PetUIAwakeSyatem : AwakeSystem<PetUI>
|
|||
|
{
|
|||
|
public override void Awake(PetUI self)
|
|||
|
{
|
|||
|
self.Awake();
|
|||
|
}
|
|||
|
}
|
|||
|
public class PetUIDestroySyatem : DestroySystem<PetUI>
|
|||
|
{
|
|||
|
public override void Destroy(PetUI self)
|
|||
|
{
|
|||
|
self.Destroy();
|
|||
|
}
|
|||
|
}
|
|||
|
public class PetUI : Entity
|
|||
|
{
|
|||
|
public FUI_PetUI ui;
|
|||
|
private NTexture nTexture;
|
|||
|
private Camera rtCamera;
|
|||
|
private Transform skinTran;
|
|||
|
private RenderTexture rt;
|
|||
|
public void Awake()
|
|||
|
{
|
|||
|
ui = GetParent<FUI_PetUI>();
|
|||
|
AwakeAsync().Coroutine();
|
|||
|
}
|
|||
|
private async ETVoid AwakeAsync()
|
|||
|
{
|
|||
|
|
|||
|
ShowSkin(2102).Coroutine();
|
|||
|
await ETTask.CompletedTask;
|
|||
|
}
|
|||
|
|
|||
|
private async ETVoid ShowSkin(int petId)
|
|||
|
{
|
|||
|
PetConfig petConfig = PetConfigCategory.Instance.Get(petId);
|
|||
|
if (petConfig == null) return;
|
|||
|
skinTran = await ResourceViewHelper.LoadPrefabAsync(petConfig.PrefabId);
|
|||
|
if (nTexture == null)
|
|||
|
{
|
|||
|
var characterTran = await ResourceViewHelper.LoadPrefabAsync(Sys_PrefabId.Character);
|
|||
|
characterTran.localPosition = new Vector3(-2100, 0, 0);
|
|||
|
rt = CreateTexture((int)this.ui.m_icon.width, (int)this.ui.m_icon.height);
|
|||
|
rtCamera = characterTran.GetComponentInChildren<Camera>();
|
|||
|
rtCamera.targetTexture = rt;
|
|||
|
nTexture = new NTexture(rt);
|
|||
|
this.ui.m_icon.texture = nTexture;
|
|||
|
}
|
|||
|
rtCamera.enabled = true;
|
|||
|
skinTran.SetParent(rtCamera.transform.parent);
|
|||
|
skinTran.localPosition =new Vector3(0,1.25f,5);
|
|||
|
}
|
|||
|
private static RenderTexture CreateTexture(int width, int height)
|
|||
|
{
|
|||
|
return new RenderTexture(width, height, 24, RenderTextureFormat.ARGB32)
|
|||
|
{
|
|||
|
antiAliasing = 1,
|
|||
|
filterMode = FilterMode.Bilinear,
|
|||
|
anisoLevel = 0,
|
|||
|
useMipMap = false
|
|||
|
};
|
|||
|
}
|
|||
|
public void Destroy()
|
|||
|
{
|
|||
|
rtCamera.enabled = false;
|
|||
|
ResourceViewHelper.DestoryPrefabAsync(skinTran);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|