68 lines
2.6 KiB
C#
68 lines
2.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
using ZXK.Framework;
|
|
using ZXK.UTility;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function 工具面板中每个工具控制
|
|
*******************************************************************************/
|
|
namespace ZXK.BYSS
|
|
{
|
|
public class ToolItemPrefab : MonoBehaviour ,IPointerDownHandler
|
|
{
|
|
public void Init(string toolName)
|
|
{
|
|
Sprite sprite = null;
|
|
switch (AppManagement.Instance._CurType)
|
|
{
|
|
case EnumCtrl.Type.None:
|
|
break;
|
|
case EnumCtrl.Type.XHBY:
|
|
sprite = Resources.Load<Sprite>(ConstCtrl.DATA_TOOLIMGXHBY_PATH + toolName);
|
|
break;
|
|
case EnumCtrl.Type.QDCY:
|
|
sprite = Resources.Load<Sprite>(ConstCtrl.DATA_TOOLIMGQDCY_PATH + toolName);
|
|
break;
|
|
case EnumCtrl.Type.CLFJ:
|
|
sprite = Resources.Load<Sprite>(ConstCtrl.DATA_TOOLIMGCLFJ_PATH + toolName);
|
|
break;
|
|
case EnumCtrl.Type.ZNYD:
|
|
sprite = Resources.Load<Sprite>(ConstCtrl.DATA_TOOLIMGZNYD_PATH + toolName);
|
|
break;
|
|
case EnumCtrl.Type.BYSS:
|
|
sprite = Resources.Load<Sprite>(ConstCtrl.DATA_TOOLIMGBYSS_PATH + toolName);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
transform.name = toolName;
|
|
transform.GetComponentInChildren<Text>(true).text = toolName;
|
|
transform.Find("ToolImg").GetComponent<Image>().sprite = sprite;
|
|
//添加设备名称
|
|
//找到组件,考核模式不显示
|
|
|
|
if (transform.Find("ToolItemNameImage") && AppManagement.Instance._CurModel != EnumCtrl.Model.Exam)
|
|
{
|
|
//设备名称文字赋值
|
|
transform.Find("ToolItemNameImage").GetComponentInChildren<Text>(true).text = toolName; ;
|
|
}
|
|
else
|
|
{
|
|
//隐藏
|
|
transform.Find("ToolItemNameImage").gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
EventCenterManager.Instance.Dispatch(EventEnum.PickTool, this, new ToolArgs
|
|
{
|
|
_ToolName = transform.name,
|
|
_ToolImg = transform.Find("ToolImg").GetComponent<Image>().sprite
|
|
});
|
|
}
|
|
}
|
|
} |