public ArtistNetworkNodeViewModel(
            ArtistViewModel viewModel, 
            AtlasHierarchy hierarchy, 
            IHierarchyNode hierarchyNode,
            IPlaylistView playlist)
            : base(viewModel.Name)
        {
            ArtistViewModel = viewModel;

            Debug.Assert(hierarchyNode is ArtistHierarchyNode);
            _hierarchyNode = (ArtistHierarchyNode) hierarchyNode; 
            _hierarchy = hierarchy;
            _playlist = playlist;

            _numTracks = GetArtistTrackCount();

            IsHighlighted = SpotifyCacheService.IsArtistFollowed(ArtistViewModel.Artist);
        }
Ejemplo n.º 2
0
    public static void BuildOnePaddingData(string name, List <Vector4> paddings, List <bool> trims, bool isPoly, AtlasHierarchy hierarchy)
    {
        bool   needCreate  = false;
        string paddingPath = PathDef.UI_ASSETS_PATH + "/atlas_tp_padding.asset";

        PaddingData data = AssetDatabase.LoadAssetAtPath <PaddingData>(paddingPath);

        if (data == null)
        {
            data       = ScriptableObject.CreateInstance <PaddingData>();
            needCreate = true;
        }

        data.RemoveAtlasItem(name);

        List <string> spriteNames = hierarchy.GetSpriteDataName();

        data.AddAtlasEx(name, isPoly, spriteNames, paddings, trims);
        CheckAtlas(data.atlas);
        if (needCreate)
        {
            AssetDatabase.CreateAsset(data, paddingPath);
        }
        else
        {
            EditorUtility.SetDirty(data);
            AssetDatabase.SaveAssets();
        }
        AssetDatabase.Refresh();
    }
Ejemplo n.º 3
0
    static void CreateSpritePrefab(string name, string path, string pathTP)
    {
        string pathPrefab   = string.Format("{0}/{1}.prefab", path, name);
        string pathColor    = string.Format("{0}/{1}_c.png", path, name);
        string pathMaterial = string.Format("{0}/{1}_mat.mat", path, name);

        if (!File.Exists(pathColor))
        {
            Debug.LogError(string.Format("File No Found: {0}", pathColor));
            return;
        }

        if (!File.Exists(pathMaterial))
        {
            Debug.LogError(string.Format("File No Found: {0}", pathMaterial));
            return;
        }

        string pathTxt = string.Format("{0}/{1}.txt", pathTP, name);
        string text    = FileHelper.ReadTextFromFile(pathTxt);
        List <TexturePacker.PackedFrame> frames = TexturePacker.ProcessToFrames(text);

        SpriteMetaData meta;
        Dictionary <string, SpriteMetaData> metas = new Dictionary <string, SpriteMetaData>();

        TextureImporter importer = AssetImporter.GetAtPath(pathColor) as TextureImporter;

        for (int i = 0; i < importer.spritesheet.Length; ++i)
        {
            meta = importer.spritesheet[i];
            if (metas.ContainsKey(meta.name))
            {
                Debug.LogError("key is already exist the dictionary:  " + meta.name);
            }
            metas.Add(meta.name, meta);
        }
        //AtlasData data = new AtlasData();
        //data.material = AssetDatabase.LoadAssetAtPath<Material>(pathMaterial);
        //data.sprites = new List<AtlasData.SpriteData>();
        Material mat = AssetDatabase.LoadAssetAtPath <Material>(pathMaterial);

        List <Sprite>  sprites = new List <Sprite>();
        List <Vector4> rts     = new List <Vector4>();
        List <bool>    trims   = new List <bool>();

        Sprite sprite = null;

        UnityEngine.Object[] objects = AssetDatabase.LoadAllAssetRepresentationsAtPath(pathColor);
        for (int i = 0; i < objects.Length; ++i)
        {
            sprite = objects[i] as Sprite;
            if (sprite == null)
            {
                continue;
            }

            bool trim = false;
            if (metas.TryGetValue(sprite.name, out meta))
            {
                trim = meta.alignment == 9;
            }

            Vector4 rt = Vector4.zero;
            foreach (TexturePacker.PackedFrame frame in frames)
            {
                string spritename = frame.name.Replace(".png", "");
                if (string.Equals(spritename, sprite.name))
                {
                    float left   = frame.spriteSourceSize.x;
                    float top    = frame.spriteSourceSize.y;
                    float right  = frame.sourceSize.x - frame.spriteSourceSize.x - frame.spriteSourceSize.width;
                    float bottom = frame.sourceSize.y - frame.spriteSourceSize.y - frame.spriteSourceSize.height;

                    rt.x = left;
                    rt.y = bottom;
                    rt.z = right;
                    rt.w = top;
                    break;
                }
            }
            sprites.Add(sprite);
            rts.Add(rt);
            trims.Add(trim);
            //data.sprites.Add(new AtlasData.SpriteData(sprite, rt, trim));
        }

        GameObject prefab = null;
        GameObject go     = null;

        if (File.Exists(pathPrefab))
        {
            prefab = AssetDatabase.LoadAssetAtPath <GameObject>(pathPrefab);
            go     = GameObject.Instantiate(prefab);
        }
        else
        {
            go = new GameObject();
        }

        go.name = name;

        AtlasHierarchy hierarchy = go.GetComponent <AtlasHierarchy>() ?? go.AddComponent <AtlasHierarchy>();

        hierarchy.SetAtlasData(sprites, mat);
        //hierarchy.atlas = data;

        if (prefab != null)
        {
            PrefabUtility.ReplacePrefab(go, prefab);
        }
        else
        {
            PrefabUtility.CreatePrefab(pathPrefab, go);
        }
        GameObject.DestroyImmediate(go);

        if (path.Contains(PathDef.UI_PATH + "/atlas_tp"))
        {
            BuildOnePaddingData(name, rts, trims, false, hierarchy);
        }
    }
 public NewReleaseHierarchyNode(NewReleaseItem newReleaseItem, AtlasHierarchy hierarchy)
     : base(hierarchy, null, 0)
 {
     NewReleaseItem = newReleaseItem;
 }
Ejemplo n.º 5
0
 public ArtistHierarchyNode(ArtistViewModel artistViewModel, AtlasHierarchy hierarchy, IHierarchyNode parent, int level)
     : base(hierarchy, parent, level)
 {
     ArtistViewModel = artistViewModel;
 }