Ejemplo n.º 1
0
    public static void CreateUGUIAtlas(string prefabpath, string atlaspath)
    {
        if (prefabpath == null && EditorUtility.DisplayDialog("选择预设", "选择ugui 图集预设", "OK"))
        {
            prefabpath = EditorUtility.OpenFilePanel("", "Assets/", "");
            prefabpath = EditorTools.GetUnityAssetPath(prefabpath);
        }

        if (atlaspath == null && EditorUtility.DisplayDialog("选择图集目录", "选择ugui 图集目录", "OK"))
        {
            atlaspath = EditorUtility.OpenFolderPanel("", "Assets/", "");
            atlaspath = EditorTools.GetUnityAssetPath(atlaspath);
        }

        if (!string.IsNullOrEmpty(prefabpath) && !string.IsNullOrEmpty(atlaspath))
        {
            GameObject       prefab     = AssetDatabase.LoadAssetAtPath <GameObject>(prefabpath);
            SpriteAtlasMgr   spritelist = prefab.TryAddComponent <SpriteAtlasMgr>();
            string[]         guids      = AssetDatabase.FindAssets("t:Sprite", new string[] { atlaspath });
            HashSet <string> hashset    = guids.ConvertHashSet();

            spritelist.Clear();
            foreach (string guid in hashset)
            {
                string assetpath             = AssetDatabase.GUIDToAssetPath(guid);
                UnityEngine.Object[] allsprs = AssetDatabase.LoadAllAssetsAtPath(assetpath);
                SpriteAtlas          atlas   = new SpriteAtlas();
                atlas.LoadSprites(allsprs);

                spritelist.InitSprites(atlas);
            }

            EditorUtility.SetDirty(prefab);
        }
    }
Ejemplo n.º 2
0
 public static void SetSprite(this UiImage image, EImagePath path, string spriteName, bool nativeSize = false)
 {
     if (string.IsNullOrEmpty(spriteName))
     {
         //Debug.LogError("XUI_Image SetSprite 不要为空! path:" + path + " spriteName:" + spriteName);
         image.Sprite = null;
         image.SetActiveByCanvasGroup(false);
     }
     else
     {
         var bSame = image.Sprite != null && spriteName == image.Sprite.name;
         if (!bSame)
         {
             SpriteAtlasMgr.LoadSprite(path.ToString(), atlas =>
             {
                 image.Sprite = atlas.GetSprite(spriteName);
                 if (nativeSize)
                 {
                     image.SetNativeSize();
                 }
                 image.SetActiveByCanvasGroup(true);
             });
         }
     }
 }
Ejemplo n.º 3
0
    public static void ClearCache()
    {
        DialogMgr.InDrawingDialog = false;
        BulletExplosion.Reset();

        UiMenuBase.ClearSelectStatus();

        //清理UI
        UiManager.Clear();

        //清理音效
        Sound.StopEnvironmentMusic();
        Sound.StopMusic();
        Sound.ClearSoundCache();

        //清理UI图集
        SpriteAtlasMgr.ClearCache();
    }
Ejemplo n.º 4
0
 void Awake()
 {
     mIns = this;
 }