Beispiel #1
0
    public void Change(Avatar.PartType type)
    {
        int           index   = resDict[type].index++ % resDict[type].resList.Count;
        List <string> reslist = resDict[type].resList;

        mAvatar.ChangePart(type, reslist[index], null);
    }
Beispiel #2
0
    public static void LoadAvatar(string wrapName, string skletonName, string hairName, string faceName, string bodyName, string cardName, string glassesName, string wingName, Action <Avatar> callback)
    {
        ResourceManager.Instance.LoadPrefabAsync(wrapName, wrapName, (obj, args) =>
        {
            Avatar avatar  = obj.GetComponent <Avatar>();
            avatar.mIsSuit = false;
            if (avatar == null)
            {
                Debuger.LogError("other", "Avatar script is missing, please Check!");
                if (callback != null)
                {
                    callback(null);
                }
            }
            else
            {
                int num = 0;
                Action CheckPackageOver = () =>
                {
                    num++;
                    if (num == (int)PartType.eMax)
                    {
                        if (callback != null)
                        {
                            callback(avatar);
                        }
                    }
                };

                //加载骨骼
                avatar.ChangePart(Avatar.PartType.eSkeleton, skletonName, () =>
                {
                    CheckPackageOver();

                    //加载头发
                    avatar.ChangePart(Avatar.PartType.eHair, hairName, () =>
                    {
                        CheckPackageOver();
                    });

                    //加载脸部
                    avatar.ChangePart(Avatar.PartType.eFace, faceName, () =>
                    {
                        CheckPackageOver();
                    });

                    //加载身体
                    avatar.ChangePart(Avatar.PartType.eBody, bodyName, () =>
                    {
                        CheckPackageOver();
                    });

                    //加载牌
                    avatar.ChangePart(Avatar.PartType.eCard, cardName, () =>
                    {
                        CheckPackageOver();
                    });

                    //加载眼镜
                    avatar.ChangePart(Avatar.PartType.eGlasses, glassesName, () =>
                    {
                        CheckPackageOver();
                    });

                    //加载翅膀
                    avatar.ChangePart(Avatar.PartType.eWing, wingName, () =>
                    {
                        CheckPackageOver();
                    });
                });
            }
        });
    }