E_ElecCompetition/Electrical_inspectionCompet.../Assets/Script/Tool objects/Tools_object_UI.cs

33 lines
736 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Tools_object_UI : MonoBehaviour
{[HideInInspector]
public string UI_name;
public string sprite_name;
public TMPro.TMP_Text text;
public Button sprite;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void change()
{
text.text = UI_name;
if (Resources.Load("UI/" + sprite_name) != null)
{
var tubiao = Resources.Load("UI/" + sprite_name);
sprite.GetComponent<Image>().sprite = Instantiate(tubiao) as Sprite;
}
}
}