示例#1
0
 static int Get(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string   arg0 = ToLua.CheckString(L, 1);
         UIResMgr o    = UIResTool.Get(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#2
0
    void Set()
    {
        int i = 0;

        foreach (TextureImporter tex in m_texs)
        {
            CheckRename(tex, m_atlasName);
            //if (string.IsNullOrEmpty(m_atlasName))
            //    tex.textureType = TextureImporterType.Sprite;
            //else
            //    tex.textureType = TextureImporterType.Default;
            tex.textureType         = TextureImporterType.Sprite;
            tex.npotScale           = TextureImporterNPOTScale.None;
            tex.spriteImportMode    = SpriteImportMode.Single;
            tex.spritePackingTag    = m_atlasName;
            tex.borderMipmap        = false;
            tex.sRGBTexture         = true;
            tex.alphaIsTransparency = true;
            tex.isReadable          = false;
            tex.mipmapEnabled       = false;
            tex.wrapMode            = TextureWrapMode.Clamp;
            tex.filterMode          = FilterMode.Bilinear;
            tex.anisoLevel          = 1;

            //if (string.IsNullOrEmpty(m_atlasName) && IsNpot(tex))
            //{//单张图而且不是2的n次方的话,自动压缩
            //    SetFormat(tex, "Standalone", TextureImporterFormat.AutomaticCompressed);
            //    SetFormat(tex, "Android", TextureImporterFormat.AutomaticCompressed);
            //    SetFormat(tex, "iPhone", TextureImporterFormat.AutomaticCompressed);
            //}
            //else
            //{
            //SetFormat(tex, "", TextureImporterFormat.ARGB32);
            //tex.textureFormat = TextureImporterFormat.ARGB32;
            //SetFormat(tex,  "Standalone", TextureImporterFormat.ARGB32);
            tex.ClearPlatformTextureSettings("Standalone");

            //SetFormat(tex, "Android", TextureImporterFormat.ETC2_RGBA8);
            //SetFormat(tex, "iPhone", TextureImporterFormat.PVRTC_RGBA4);
            EditorUtil.SetDirty(tex);
            //}
            ++i;
            EditorUtility.DisplayProgressBar("Loading", string.Format("正在修改格式和重命名,{0}/{1}", i, m_texs.Count), ((float)i / m_texs.Count) * 0.9f);
        }

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        //检查是不是要重新打包
        EditorUtility.DisplayProgressBar("Loading", string.Format("检查打包中"), 0.9f);
        EditorUtility.ClearProgressBar();
        UnityEditor.Sprites.Packer.kDefaultPolicy = "DefaultPackerPolicy";//TightPackerPolicy DefaultPackerPolicy
#if UNITY_ANDROID
        UnityEditor.Sprites.Packer.RebuildAtlasCacheIfNeeded(BuildTarget.Android, true);
#endif

#if UNITY_IPHONE
        UnityEditor.Sprites.Packer.RebuildAtlasCacheIfNeeded(BuildTarget.iOS, true);
#endif

#if UNITY_STANDALONE_WIN
        UnityEditor.Sprites.Packer.RebuildAtlasCacheIfNeeded(BuildTarget.StandaloneWindows, true);
#endif

        //打包进UI资源管理器中
        List <string> path = new List <string>();
        foreach (TextureImporter tex in m_texs)
        {
            //Debuger.Log("资源路径"+tex.assetPath);
            path.Add(tex.assetPath);
        }

        string modName = "";

        string   pathStr = path[0];
        string[] pList   = pathStr.Split('/');
        for (int n = 0; n < pList.Length; n++)
        {
            if (pList[n] == "Atlas")
            {
                modName = pList[n + 1];
            }
        }

        UIResMgr uiRes = UIResTool.Get(modName);
        if (Application.isPlaying)
        {
            Debug.LogError("运行中不能设置图片");
            return;
        }
        uiRes.PackByPath(path);
    }