示例#1
0
        public static AssetBundle GetAssetBundle(string path)
        {
            try
            {
                string      absUri = "file:///" + GetModPath().Replace("\\", "/") + "/" + path;
                WWW         www    = new WWW(absUri);
                AssetBundle bundle = www.assetBundle;

                LoggerUtils.Log(path + " bundle loading " + ((bundle == null) ? "failed " + www.error : "succeeded"));
                String[] allAssets = bundle.GetAllAssetNames();
                foreach (String asset in allAssets)
                {
                    LoggerUtils.Log("asset is: " + asset);
                }
                return(bundle);
            }
            catch (Exception e)
            {
                Debug.Log("Exception trying to load bundle file!" + e.ToString());
                return(null);
            }
        }
示例#2
0
        public static bool AddFonts()
        {
            foreach (KeyValuePair <string, string> pair in m_desiredFonts)
            {
                AssetBundle bundle = FileUtils.GetAssetBundle(pair.Value);

                if (bundle == null)
                {
                    return(false);
                }

                Font[] font = bundle.LoadAllAssets <Font>();

                LoggerUtils.Log("Font is loaded?" + (font.Length > 0));
                if (font != null)
                {
                    m_fontStore[pair.Key] = font[0];
                }
                bundle.Unload(false);
            }

            return(true);
        }