Esempio n. 1
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Left)//마우스 좌클릭하면, 해당하는 이벤트를 할 수 있음.
        {
            Debug.Log(this.name + " are Clicked!");

            //! 아이디어, 아이템을 클릭 한 후 UI가 보이게되면, 해당 tag를 가진 ItemManager의 모든 child값을 받아서, 그 걸 통해 해당 prefab을 content에 child로 넣어준다.
            // thisItem.transform.parent = transform; 이런식으로 content에 script를 만들면됨.


            Debug.Log("my father : " + transform.root.gameObject.name);

            SetUI.Item temp = new SetUI.Item(Category, Name, Price, ImageURL, URL, Image);
            transform.root.gameObject.GetComponent <SetUI>().SetThis(temp);
        }
    }
Esempio n. 2
0
    public void InitProductPrefab(SetUI.Item item)
    {
        Category = item.GetCategory();
        Name     = item.GetName();
        Price    = item.GetPrice();
        ImageURL = item.GetImageURL();
        URL      = item.GetURL();
        Image    = item.GetImage();

        UnityEngine.UI.Text productName = transform.GetChild(0).GetComponent <UnityEngine.UI.Text>();
        productName.text = Name;
        UnityEngine.UI.Text productPrice = transform.GetChild(1).GetComponent <UnityEngine.UI.Text>();
        productPrice.text = "가격 : " + Price + " 원";

        UnityEngine.UI.Image img = transform.GetChild(2).GetComponent <Image>();
        img.sprite = Sprite.Create(Image, new Rect(0.0f, 0.0f, Image.width, Image.height), new Vector2(0.5f, 0.5f), 100.0f);
    }