Example #1
0
    public static MahjongPai CreateMahjongPai(Transform parent, Vector3 localPos, Hai info, bool isShow = true)
    {
        if (Hai.IsValidHai(info) == false)
        {
            Debug.LogError("PlayerUI: Invalid hai for ID == " + info.ID);
            return(null);
        }

        GameObject newInst = ResManager.CreateMahjongObject();

        newInst.transform.parent        = parent;
        newInst.transform.localScale    = Vector3.one;
        newInst.transform.localPosition = localPos;

        // set component info.
        MahjongPai pai = newInst.GetComponent <MahjongPai>();

        if (pai == null)
        {
            pai = newInst.AddComponent <MahjongPai>();
        }

        pai.SetInfo(info);
        pai.Init();
        pai.UpdateImage();

        if (isShow)
        {
            pai.Show();
        }
        else
        {
            pai.Hide();
        }

        return(pai);
    }