少年修仙传客户端代码仓库
client_linchunjie
2019-05-08 3db053dc0199bafc19e899c8ce73de8a53b5d0f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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<VideoClip>(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<GameObject>(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;
    }
 
}