コード例 #1
0
    public override void Show()
    {
        base.Show();
        Logger.log("Showing context menu for " + item.name);
        GameObject contextButtoninstance = Instantiate(contextMenuButtonPrefab, contextMenuParent);

        contextButtoninstance.GetComponent <Button>().onClick.AddListener(() => item.ContextAction());
        contextButtoninstance.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = item.contextActionName;

        if (item.droppable)
        {
            GameObject dropButtonInstance = Instantiate(contextMenuButtonPrefab, contextMenuParent);
            dropButtonInstance.GetComponent <Button>().onClick.AddListener(() => item.Drop());
            dropButtonInstance.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = "Drop";
        }
        Vector2 menuPos = Input.mousePosition;

        menuPos.x         += 150;
        menuPos.y         -= 60;
        transform.position = menuPos;
    }