ShanxiKnowledgeBase/SXElectricityInformationAcq.../Assets/Scripts/CharacterEquipWindow/CharacterEquipInfoManager.cs

63 lines
1.8 KiB
C#

using MotionFramework;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace DefaultNamespace
{
[ScriptDescription("人物装备信息管理类")]
public class CharacterEquipInfoManager : MonoBehaviour
{
public static CharacterEquipInfoManager Instance;
public RawImage raw;
public RenderTexture renderTexture;
// 定义装备插槽
public Transform headSlot;
public Transform bodySlot;
public Transform HandSlot;
// 存储当前装备的字典
public List<Button> infoBt;
private void Awake()
{
Instance = this;
}
public bool Equipment(string equName, bool isB)
{
bool isEquip = false;
Material m = CharacterEquipManager.Instance.changeEquip(equName, isB);
switch (equName)
{
case "安全帽":
headSlot.GetComponent<SkinnedMeshRenderer>().material = m;
isEquip = true;
break;
case "工作服":
bodySlot.GetComponent<SkinnedMeshRenderer>().material = m; isEquip = true;
break;
case "纱布手套":
HandSlot.GetComponent<SkinnedMeshRenderer>().material = m; isEquip = true;
break;
}
foreach (var v in infoBt)
{
if (v.name == equName)
{
v.transform.Find("ico").gameObject.SetActive(isB);
}
}
renderTexture.Release(); // 释放当前RenderTexture
renderTexture.Create(); // 重新创建RenderTexture
return isEquip;
}
}
}