Exemple #1
0
        /// <summary>
        /// Un-asigns avatar texture from a character with the provided ID.
        /// </summary>
        public void RemoveAvatarTextureFor(string characterId)
        {
            if (!charIdToAvatarPathMap.ContainsKey(characterId))
            {
                return;
            }

            charIdToAvatarPathMap.Remove(characterId);
            OnCharacterAvatarChanged?.Invoke(new CharacterAvatarChangedArgs(characterId, null));
        }
Exemple #2
0
        /// <summary>
        /// Assigns avatar texture with the provided (local) path to a character with the provided ID.
        /// </summary>
        public void SetAvatarTexturePathFor(string characterId, string avatarTexturePath)
        {
            if (!ActorExists(characterId))
            {
                Debug.LogError($"Failed to assign `{avatarTexturePath}` avatar texture to `{characterId}` character: character with the provided ID not found.");
                return;
            }

            if (!AvatarTextureExists(avatarTexturePath))
            {
                Debug.LogError($"Failed to assign `{avatarTexturePath}` avatar texture to `{characterId}` character: avatar texture with the provided path not found.");
                return;
            }

            charIdToAvatarPathMap.TryGetValue(characterId ?? string.Empty, out var initialPath);
            charIdToAvatarPathMap[characterId] = avatarTexturePath;

            if (initialPath != avatarTexturePath)
            {
                var avatarTexture = GetAvatarTextureFor(characterId);
                OnCharacterAvatarChanged?.Invoke(new CharacterAvatarChangedArgs(characterId, avatarTexture));
            }
        }