using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Video; public class VideoLoader { public static VideoClip Load(string name) { VideoClip mp4 = null; if (Application.isEditor) { #if UNITY_EDITOR var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath, "Movie/", name, ".mp4"); mp4 = UnityEditor.AssetDatabase.LoadAssetAtPath(path); if (mp4 == null) { DebugEx.LogErrorFormat("VideoLoader.Load() => 加载不到资源: {0}.", name); } #endif } else { var assetInfo = new AssetInfo("movie", name); mp4 = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as VideoClip; } return mp4; } public static GameObject LoadPlayer() { GameObject prefab = null; if (Application.isEditor) { #if UNITY_EDITOR var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath, "Movie/MoviePlayer.prefab"); prefab = UnityEditor.AssetDatabase.LoadAssetAtPath(path); #endif } else { var assetInfo = new AssetInfo("movie", "MoviePlayer"); prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject; } if (prefab == null) { DebugEx.LogError("VideoLoader.LoadPlayer() => 加载不到资源: MoviePlayer."); } return prefab; } }