You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
akadoc/Assets/scripts/Gui_AbilityButton.cs

52 lines
911 B

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Gui_AbilityButton : MonoBehaviour{
public int spellID;
void Awake(){
button = GetComponent<Button>();
icon = GetComponent<Image>();
name = GetComponentInChildren<Text>();
}
void Start(){
SetSpellID(spellID);
}
void SetSpellID(int _spellID){
spellID = _spellID;
//Set image, callback
var st = Rdb.GetTable("spells");
//Set icon
string sIcon = st.GetValue<string>(spellID, "icon");
var iconImage = Resources.Load<Sprite>(sIcon);
if(iconImage==null){
Debug.LogError("Could not open "+sIcon);
}
else
icon.sprite = iconImage;
//Set name
name.text = Rdb.GetStrRef(st.GetValue<int>(spellID, "name_strref"));
//Execute script
button.onClick.AddListener(()=>{
Debug.Log("Clicked");
});
}
private int i;
private Button button;
private Image icon;
private Text name;
}