示例#1
0
    /// <summary>
    /// 刷新 图集信息
    /// </summary>
    /// <param name="uiAtla"></param>
    /// <param name="path_texture"></param>
    public static void RefreshAtlaSprites(AssetUIAtlas uiAtla, string path_texture)
    {
        if (uiAtla == null || string.IsNullOrEmpty(path_texture))
        {
            return;
        }

        FillSpriteArray(uiAtla.sprites, path_texture);
    }
示例#2
0
 public void UF_RemoveAtla(string atlaName)
 {
     if (m_DicAtlaSets.ContainsKey(atlaName))
     {
         AssetUIAtlas atlas = m_DicAtlaSets [atlaName];
         m_DicAtlaSets.Remove(atlaName);
         UnityEngine.Object.Destroy(atlas);
         //释放AB引用
         AssetSystem.UF_GetInstance().UF_RelaseRef(atlaName);
     }
 }
示例#3
0
        public Sprite UF_GetSprite(string spriteName)
        {
            if (string.IsNullOrEmpty(spriteName))
            {
                return(null);
            }
            string atlaName = UF_getAtlaName(spriteName);

            if (!string.IsNullOrEmpty(atlaName))
            {
                AssetUIAtlas atlas = UF_GetAtlas(atlaName);
                if (atlas != null)
                {
                    return(atlas.UF_GetSprite(spriteName));
                }
            }
            return(null);
        }
示例#4
0
 internal AssetUIAtlas UF_GetAtlas(string atlaName)
 {
     atlaName = atlaName.ToLower();
     if (m_DicAtlaSets.ContainsKey(atlaName))
     {
         return(m_DicAtlaSets [atlaName]);
     }
     else
     {
         AssetUIAtlas atlas = AssetSystem.UF_GetInstance().UF_LoadObjectImage(atlaName) as AssetUIAtlas;
         //设置AB引用
         AssetSystem.UF_GetInstance().UF_RetainRef(atlaName);
         if (atlas == null)
         {
             Debugger.UF_Warn(string.Format("This UIAlta[ {0} ] you want to load is Null", atlaName));
         }
         else
         {
             m_DicAtlaSets.Add(atlaName, atlas);
         }
         return(atlas);
     }
 }
示例#5
0
        //获取动画序列数组
        public List <Sprite> UF_GetAnimateSqueueSprites(string prefixSpriteName)
        {
            string atlaName = UF_getAtlaName(prefixSpriteName);

            if (!string.IsNullOrEmpty(atlaName))
            {
                AssetUIAtlas atlas = UF_GetAtlas(atlaName);
                if (atlas != null)
                {
                    List <Sprite> list   = new List <Sprite> ();
                    int           idx    = 1;
                    Sprite        sprite = atlas.UF_GetSpriteInMap(prefixSpriteName + idx);
                    while (sprite != null)
                    {
                        list.Add(sprite);
                        idx++;
                        sprite = atlas.UF_GetSpriteInMap(prefixSpriteName + idx);
                    }
                    return(list);
                }
            }
            return(null);
        }
示例#6
0
    public override void OnInspectorGUI()
    {
        AssetUIAtlas uiAtla = target as AssetUIAtlas;


        GUILayout.Space(6);
        EditorGUIUtility.labelWidth = 110;


        GUILayout.Label(string.Format("图集: "));

        Texture2D atla_texture = EditorGUILayout.ObjectField(uiAtla.texture, typeof(Texture2D), true) as Texture2D;

        string path_texture = AssetDatabase.GetAssetPath(atla_texture);

        if (atla_texture != null)
        {
            GUILayout.Label(string.Format("{0} x {1}\n{2}\n{3}",
                                          atla_texture.width,
                                          atla_texture.height,
                                          atla_texture.format,
                                          atla_texture.filterMode));
        }

        if (EditorTools.DrawHeader("显示图集", true, false))
        {
            Rect rect = GUILayoutUtility.GetRect(320, 320, GUI.skin.box);

            GUI.Box(rect, uiAtla.texture);
        }

        if (uiAtla.sprites != null)
        {
            GUILayout.Label(string.Format("元件数[{0}]", uiAtla.sprites.Count));
        }

        DrawTargetArray(uiAtla.sprites, true);

        if (GUILayout.Button("刷新元件"))
        {
            FillSpriteArray(uiAtla.sprites, path_texture);
        }

        if (uiAtla.texture != atla_texture)
        {
            if (uiAtla.texture != null)
            {
                AssetImporter ai = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(uiAtla.texture));
                ai.assetBundleName = string.Empty;
            }

            if (atla_texture != null)
            {
                string assetbundleName = AssetDatabase.GetAssetPath(target)
                                         .Replace(".prefab", "")
                                         .Replace(".asset", "")
                                         .Replace("Assets/AssetBases/PrefabAssets/", "");
                AssetImporter ai = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(atla_texture));
                ai.assetBundleName = assetbundleName;
            }

            uiAtla.texture = atla_texture;

            FillSpriteArray(uiAtla.sprites, path_texture);



            EditorTools.SetDirty(uiAtla);
        }
    }