예제 #1
0
        private void FillMaterialContentsInSprite(CocoAssetSpriteHolder spriteHolder, string itemId, Dictionary <string, bool> materialPaths)
        {
            var usedPath = string.Empty;

            foreach (var kvpMaterialPath in materialPaths)
            {
                var materialPath = kvpMaterialPath.Key;
                var materialId   = Path.GetFileNameWithoutExtension(materialPath);
                var expectItemId = ExtractItemId(materialId);
                if (expectItemId == itemId)
                {
                    var materialHolder = new CocoAssetMaterialHolder
                    {
                        id = materialId, assetPath = GetRelativePath(materialPath)
                    };
                    spriteHolder.materialHolder = materialHolder;
                    usedPath = materialPath;
                    break;
                }
            }


            if (string.IsNullOrEmpty(usedPath))
            {
                Debug.LogFormat("[{0}]->FillSpriteContentsInItem: can NOT found sprite material for sprite [{1}({2})]!", GetType().Name,
                                spriteHolder.id, itemId);
            }
            else
            {
                materialPaths [usedPath] = true;
            }
        }
예제 #2
0
        private void FillSpriteContentsInItem(CocoDressItemHolder itemHolder, Dictionary <string, bool> spritePaths,
                                              Dictionary <string, bool> spriteMaterialPaths)
        {
            var usedPath = string.Empty;

            foreach (var kvpSpritePath in spritePaths)
            {
                var spritePath = kvpSpritePath.Key;
                var spriteId   = Path.GetFileNameWithoutExtension(spritePath);
                if (string.IsNullOrEmpty(spriteId))
                {
                    continue;
                }
                if (!itemHolder.id.StartsWith(spriteId))
                {
                    continue;
                }

                var spriteHolder = new CocoAssetSpriteHolder {
                    id = spriteId, assetPath = GetRelativePath(spritePath)
                };
                itemHolder.spriteHolders.Add(spriteHolder);

                FillMaterialContentsInSprite(spriteHolder, itemHolder.id, spriteMaterialPaths);
                usedPath = spritePath;
                break;
            }

            if (string.IsNullOrEmpty(usedPath))
            {
                Debug.LogErrorFormat("[{0}]->FillSpriteContentsInItem: can NOT found sprite for item [{1}]!", GetType().Name, itemHolder.id);
            }
            else
            {
                spritePaths [usedPath] = true;
            }
        }