// Start is called before the first frame update void Start() { foreach (var child in GetComponentsInChildren <Button>()) { child.onClick.AddListener(() => { Sprite sprite = child.GetComponent <Image>().sprite; RuntimeAltasItem item = child.GetComponent <RuntimeAltasItem>(); if (_onSelected != null) { _onSelected(sprite, item.Path); } }); } }
// Start is called before the first frame update void Start() { ShowName id = ShowName.ICON_1; foreach (Transform trans in transform) { RuntimeAltasItem altasItem = trans.gameObject.AddComponent <RuntimeAltasItem>(); ShowItem item = trans.gameObject.AddComponent <ShowItem>(); item.Init(id); id++; item.AddListener(() => { _selectedItem = item; _altasItem = altasItem; }); } }
private static void SetPath() { foreach (GameObject go in Selection.gameObjects) { foreach (Transform trans in go.transform) { if (trans.GetComponent <Image>() == null) { continue; } Sprite sprite = trans.GetComponent <Image>().sprite; string path = AssetDatabase.GetAssetPath(sprite); path = Application.dataPath + path.Substring(6); RuntimeAltasItem item = trans.GetComponent <RuntimeAltasItem>(); if (item == null) { item = trans.gameObject.AddComponent <RuntimeAltasItem>(); } item.Path = path; } } }
public void Init(ShowName id) { ID = id; _image = GetComponent <Image>(); _altasItem = GetComponent <RuntimeAltasItem>(); }