I'm trying to build an application for OculusGO but the file is too big so I'm working with AssetBundles to lower the size. I've worked with this link so far Build and load Assetbundles in Unity but I don't know how to do this with videos.
I currently have this as my loader for the application but I need it to load from the AssetBundle
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
[CreateAssetMenu(fileName = "Situation", menuName = "Situation", order = 1)]
public class SituationData : ScriptableObject
{
public VideoClip video;
public AssetBundle.LoadFromFileAsync(Assets/StreamingAssets/AssetBundles);
public Sprite screenshot;
public Sprite situationPanel;
public Sprite situationPanelSelected;
public string objectiveText;
public string sessionName;
public float startRotation;
IEnumerator LoadAsset(string assetBundleName, string objectNameToLoad)
{
string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "AssetBundles");
filePath = System.IO.Path.Combine(filePath, assetBundleName);
//Load "animals" AssetBundle
var assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(filePath);
yield return assetBundleCreateRequest;
AssetBundle asseBundle = assetBundleCreateRequest.assetBundle;
//Load the "dog" Asset (Use Texture2D since it's a Texture. Use GameObject if prefab)
AssetBundleRequest asset = asseBundle.LoadAssetAsync<VideoClip>(objectNameToLoad);
yield return asset;
//Retrieve the object (Use Texture2D since it's a Texture. Use GameObject if prefab)
VideoClip loadedAsset = asset.asset as VideoClip;
//Do something with the loaded loadedAsset object (Load to RawImage for example)
image.texture = loadedAsset;
}
}
Just for clarity, I've already built the AssetBundles, I just don't know how to load those in instead of the actual video files so I can reduce the file size.