Пример #1
0
    // 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);
                }
            });
        }
    }
Пример #2
0
    // 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;
            });
        }
    }
Пример #3
0
    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;
            }
        }
    }
Пример #4
0
 public void Init(ShowName id)
 {
     ID         = id;
     _image     = GetComponent <Image>();
     _altasItem = GetComponent <RuntimeAltasItem>();
 }