Example #1
0
        public void SetAvatar(Race race)
        {
            if (AvatarParent == null)
            {
                return;
            }

            if (AvatarParent.childCount > 0)
            {
                for (var i = 0; i < AvatarParent.childCount; i++)
                {
                    Destroy(AvatarParent.GetChild(i).gameObject);
                }
            }

            var avatarObj = Resources.Load <GameObject>(HeroHelper.GetAvatarName(race));

            Object.Instantiate(avatarObj, AvatarParent);
        }