public void OnDisabled()
 {
     if (assetsBundle)
     {
         assetsBundle.Unload(true);
         AssetBundle.Destroy(assetsBundle);
         Utils.log("Disabled");
     }
 }
Beispiel #2
0
        public void OnDisabled()
        {
            ModLoader.removeConfigUI();

            if (loadedBundle)
            {
                loadedBundle.Unload(true);
                AssetBundle.Destroy(loadedBundle);
                PPFXUtility.log("Unloaded existing asset bundle.");
            }

            PPFXUtility.log(ModName + " " + VersionString + " disabled.");
        }
Beispiel #3
0
        public static void FirstTimeFontLoad()
        {
            List <Font> tempFontList = new List <Font>();

            #region inbuilt fonts

            Stream      ntf             = Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomMenuText.Fonts.NeonTubes");
            AssetBundle neonBundle      = AssetBundle.LoadFromStream(ntf);
            GameObject  NeonTubesPrefab = neonBundle.LoadAsset <GameObject>("Text");
            NeonTubesPrefab.name = "NeonTubes";
            Font NeonTubes = new Font(NeonTubesPrefab, "Neon Tubes 2", true);
            ntf.Close();
            neonBundle.Unload(false);

            Stream      bf         = Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomMenuText.Fonts.Beon");
            AssetBundle beonBundle = AssetBundle.LoadFromStream(bf);
            GameObject  BeonPrefab = beonBundle.LoadAsset <GameObject>("Text");
            Font        Beon       = new Font(BeonPrefab, "Beon", true);
            bf.Close();
            AssetBundle.Destroy(beonBundle);
            beonBundle.Unload(false);
            #endregion

            Plugin.Log.Notice("Searching " + Plugin.FONT_PATH + " For Font Files");
            var fonts = Directory.GetFiles(Plugin.FONT_PATH);
            Plugin.Log.Notice(fonts.Length + " External Fonts");
            if (fonts.Length > 0)
            {
                Plugin.Log.Notice("First Font: " + fonts[0]);
                Plugin.Log.Notice("First Font: " + fonts[0].Substring(Plugin.FONT_PATH.Length));
                for (int i = 0; i < fonts.Length; i++)
                {
                    Plugin.Log.Notice("Adding font " + fonts[i] + " " + i);
                    AssetBundle fontBundle = AssetBundle.LoadFromFile(fonts[i]);
                    GameObject  prefab     = fontBundle.LoadAsset <GameObject>("Text");
                    prefab.name = fonts[i].Substring(Plugin.FONT_PATH.Length);
                    Font tempFont = new Font(prefab, fonts[i].Substring(Plugin.FONT_PATH.Length));
                    AssetBundle.Destroy(fontBundle);
                    fontBundle.Unload(false);
                }
            }
            FontList = tempFontList.ToArray();
            Plugin.Log.Info("Font loading complete, ");
            Plugin.Log.Info("Found " + FontList.Length + " Total Fonts.");
        }
Beispiel #4
0
    void LoadAssetToView()
    {
        grayPanel.SetActive(true);
//        buttonPanel.SetActive(false);
        Models jsonObject = JsonUtility.FromJson <Models>(jsonResult);

        var pos = 0;

        if (switchCount == 0)
        {
            pos = switchCount;
            switchCount++;
        }
        else
        {
            if (switchCount >= jsonObject.body.Length)
            {
                //Unload asset bundle
                AssetBundle.Destroy(finalObjects.Parent.transform
                                    .Find(GetFullModelName(finalObjects.Model.name)).gameObject);
                bundle.Unload(true);
                switchCount = 0;
                pos         = switchCount;
            }
            else
            {
                //Unload asset bundle
                AssetBundle.Destroy(finalObjects.Parent.transform
                                    .Find(GetFullModelName(finalObjects.Model.name)).gameObject);
                bundle.Unload(true);
                pos = switchCount;
            }

            switchCount++;
        }

        //Load model at 'pos'
        StartCoroutine(DownloadModelOrGetFromCache(pos, jsonObject));
    }