static int GetTextInfo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         TMPro.TextMeshProUGUI obj = (TMPro.TextMeshProUGUI)ToLua.CheckObject(L, 1, typeof(TMPro.TextMeshProUGUI));
         string             arg0   = ToLua.CheckString(L, 2);
         TMPro.TMP_TextInfo o      = obj.GetTextInfo(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        image.sprite = plan.craftItem.GetComponent <SpriteRenderer>().sprite;
        text.text    = plan.craftItem.name;

        for (int i = 0; i < plan.plan.Count; ++i)
        {
            GameObject g = Instantiate(craftitem, hoverInfo.transform);
            (g.GetComponent(typeof(CraftItem)) as CraftItem).itemName = plan.plan[i].item.name;
            (g.GetComponent(typeof(CraftItem)) as CraftItem).number   = plan.plan[i].number;
            (g.GetComponent(typeof(CraftItem)) as CraftItem).items    = parent.player.detectItem;
            g.GetComponent <Image>().sprite = plan.plan[i].item.GetComponent <SpriteRenderer>().sprite;
            g.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = "" + plan.plan[i].number;
            g.GetComponent <RectTransform>().anchoredPosition             = new Vector2(g.GetComponent <RectTransform>().anchoredPosition.x + 50 * i, g.GetComponent <RectTransform>().anchoredPosition.y);
        }

        float size = text.GetTextInfo(text.text).textComponent.GetPreferredValues().x + 20;

        hoverInfo.GetComponent <RectTransform>().sizeDelta = new Vector2((60 * (plan.plan.Count) > size) ? (60 * (plan.plan.Count)) : size + 20, hoverInfo.GetComponent <RectTransform>().sizeDelta.y);
        hoverInfo.SetActive(false);
    }