Skip to content

iiDkRemastered/GorillaMedia

Ownership not verified 0
Open on GitHub

Viewing main at commit e83d85e98d“added tracker telemetry”· 19 days ago

43 lines · 1.2 KBRaw on GitHub
using System.IO;
using System.Reflection;
using UnityEngine;

namespace GorillaMedia
{
    public class AssetManager
    {
        private static AssetBundle assetBundle;

        private static void LoadAssetBundle()
        {
            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("GorillaMedia.Resources.media");
            if (stream != null)
                assetBundle = AssetBundle.LoadFromStream(stream);
            else
                Debug.LogError("Failed to load assetbundle");
        }

        public static T LoadObject<T>(string assetName) where T : Object
        {
            T gameObject = null;

            if (assetBundle == null)
                LoadAssetBundle();

            gameObject = Object.Instantiate(assetBundle.LoadAsset<T>(assetName));
            return gameObject;
        }

        public static T LoadAsset<T>(string assetName) where T : Object
        {
            T gameObject = null;

            if (assetBundle == null)
                LoadAssetBundle();

            gameObject = assetBundle.LoadAsset(assetName) as T;
            return gameObject;
        }
    }
}

Code is shown from GitHub as-is. Linking a repository doesn’t prove that a release file on Canopy was built from it.