Exemplo n.º 1
0
    public static PetHonor CeateNew(int _index, int _id, GameObject gameParent)
    {
        Object prefab = exResources.GetResource(ResourceType.GUI, "SpiritAnimal/PetTitle");

        if (prefab == null)
        {
            GameSys.LogError("找不到宠物头衔预制");
            return(null);
        }
        GameObject obj = Instantiate(prefab) as GameObject;

        obj.transform.parent        = gameParent.transform;
        obj.transform.localPosition = new Vector3();
        obj.transform.localScale    = Vector3.one;
        prefab = null;
        PetHonor itemUI = obj.GetComponent <PetHonor>();

        if (itemUI == null)
        {
            GameSys.LogError("预制上找不到组件:<PetHonor>");
            return(null);
        }
        itemUI.TitleRef = ConfigMng.Instance.GetTitlesRef(_id);
        return(itemUI);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 显示头衔
    /// </summary>
    void ShowHonor(int _growTitle)
    {
        if (parent != null)
        {
            UIExGrid grid = parent.GetComponent <UIExGrid>();
            if (grid != null)
            {
                grid.maxPerLine = honorList.Count;

                for (int i = 0, max = petHonorList.Count; i < max; i++)
                {
                    petHonorList[i].gameObject.SetActive(false);
                }

                for (int i = 0; i < honorList.Count; i++)
                {
                    if (petHonorList.Count <= i)
                    {
                        PetHonor item = PetHonor.CeateNew(i, honorList[i].type, parent);
                        item.gameObject.SetActive(true);
                        if (_growTitle >= honorList[i].type)
                        {
                            item.honorIcon.IsGray = UISpriteEx.ColorGray.normal;
                        }
                        else
                        {
                            item.honorIcon.IsGray = UISpriteEx.ColorGray.Gray;
                        }
                        petHonorList.Add(item);
                    }
                    else
                    {
                        petHonorList[i].TitleRef = ConfigMng.Instance.GetTitlesRef(honorList[i].type);
                        petHonorList[i].gameObject.SetActive(true);
                        if (petHonorList[i].TitleRef != null)
                        {
                            if (_growTitle >= honorList[i].type)
                            {
                                petHonorList[i].honorIcon.IsGray = UISpriteEx.ColorGray.normal;
                            }
                            else
                            {
                                petHonorList[i].honorIcon.IsGray = UISpriteEx.ColorGray.Gray;
                            }
                        }
                    }
                }
                grid.repositionNow = true;
            }
        }
    }