コード例 #1
0
 static int Add(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIResMgr arg0 = (UIResMgr)ToLua.CheckUnityObject(L, 1, typeof(UIResMgr));
         string   arg1 = ToLua.CheckString(L, 2);
         UIResTool.Add(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #2
0
 static int GetSprite(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string             arg0 = ToLua.CheckString(L, 1);
         UnityEngine.Sprite o    = UIResTool.GetSprite(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #3
0
 static int HasMod(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         bool   o    = UIResTool.HasMod(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #4
0
ファイル: PanelManager.cs プロジェクト: tongxingyang/TanksWar
    void LoadPrefabAsync(string modName, string abName, string assetName, LuaFunction func = null, LuaTable tab = null)
    {
        ResManager.LoadPrefab(abName, assetName, delegate(UnityEngine.Object[] objs)
        {
            if (objs.Length == 0)
            {
                return;
            }
            GameObject prefab = objs[0] as GameObject;
            if (prefab == null)
            {
                return;
            }

            GameObject go = Instantiate(prefab) as GameObject;
            go.name       = assetName;

            if (assetName == "UIResMgr")
            {
                UIResMgr uiResMgr = go.GetComponent <UIResMgr>();
                if (uiResMgr == null)
                {
                    Debug.LogError("abName : " + abName + "  assetName : " + assetName + " 没有UIResMgr脚本");
                    return;
                }
                UIResTool.Add(uiResMgr, modName);
                return;
            }

            RectTransform rt = go.GetComponent <RectTransform>();
            if (rt != null && m_canvasRoot != null)
            {
                rt.SetParent(m_canvasRoot, false);
                rt.anchorMin          = Vector2.zero;
                rt.anchorMax          = Vector2.one;
                rt.localScale         = Vector3.one;
                rt.anchoredPosition3D = Vector3.zero;
                rt.sizeDelta          = Vector2.zero;

                m_panels[assetName] = go;
                //AddSoundFX(panel);//添加UI音效
                if (func != null)
                {
                    func.Call(tab, go);
                }
            }
        });
    }
コード例 #5
0
ファイル: PanelManager.cs プロジェクト: tongxingyang/TanksWar
    IEnumerator LoadPrefab(string modName, string assetName, LuaFunction func = null, LuaTable tab = null)
    {
        GameObject prefab = Resources.Load("Prefab/" + modName + "/" + assetName) as GameObject;

        while (prefab == null)
        {
            Debug.Log("加载资源-------" + assetName);
            yield return(1);
        }
        GameObject go = Instantiate(prefab) as GameObject;

        go.name = assetName;
        RectTransform rt = go.GetComponent <RectTransform>();

        if (rt != null && m_canvasRoot != null)
        {
            rt.SetParent(m_canvasRoot);
            rt.anchorMin          = Vector2.zero;
            rt.anchorMax          = Vector2.one;
            rt.localScale         = Vector3.one;
            rt.anchoredPosition3D = Vector3.zero;
            rt.sizeDelta          = Vector2.zero;

            m_panels[assetName] = go;
            //AddSoundFX(panel);//添加UI音效
            if (func != null)
            {
                func.Call(tab, go);
            }
        }

        if (assetName == "UIResMgr")
        {
            UIResMgr uiResMgr = go.GetComponent <UIResMgr>();
            if (uiResMgr == null)
            {
                Debug.LogError("modName : " + modName + "  assetName : " + assetName + " 没有UIResMgr脚本");
                yield break;
            }
            UIResTool.Add(uiResMgr, modName);
        }
        yield break;
    }
コード例 #6
0
        public void Set(string spriteName)
        {
            if (this.overrideSprite == null && string.IsNullOrEmpty(spriteName))
            {
                return;
            }
            if (this.overrideSprite != null && spriteName == this.overrideSprite.name)
            {
                return;
            }

            if (string.IsNullOrEmpty(spriteName))
            {
                this.overrideSprite = Transparent;
                return;
            }

            //color = Color.white;
            this.overrideSprite = UIResTool.GetSprite(spriteName);
        }
コード例 #7
0
    static int _CreateUIResTool(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                UIResTool obj = new UIResTool();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UIResTool.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #8
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);
    }