50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author Adam
|
||
//@create 20240715
|
||
//@company Adam
|
||
//
|
||
//@description:
|
||
//============================================================
|
||
namespace Components
|
||
{
|
||
public class ToolParentItem : MonoBehaviour
|
||
{
|
||
public Image icon;
|
||
public Text countText;
|
||
public Button selfBtn;
|
||
private Button colseBtn;
|
||
public RectTransform content;
|
||
public GameObject smallObjPrefab;
|
||
public GameObject smallToolBar;
|
||
public WearAndUse wearAndUse = WearAndUse.defaultModel;
|
||
// Use this for initialization
|
||
|
||
public void SetCount(Sprite _icon, int _count)
|
||
{
|
||
countText.text = $"×{_count}";
|
||
icon.sprite = _icon;
|
||
}
|
||
public void SetIconAndCountText( Transform t)
|
||
{
|
||
smallToolBar = Instantiate(smallObjPrefab, t);
|
||
content = smallToolBar.transform.GetChild(0).Find("content").GetComponent<RectTransform>();
|
||
colseBtn = smallToolBar.transform.GetChild(0).Find("close").GetComponent<Button>();
|
||
selfBtn = GetComponent<Button>();
|
||
colseBtn.onClick.AddListener(() =>
|
||
{
|
||
smallToolBar.gameObject.SetActive(false);
|
||
});
|
||
selfBtn.onClick.AddListener(() =>
|
||
{
|
||
smallToolBar.gameObject.SetActive(true);
|
||
});
|
||
smallToolBar.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|