Unity UMP打包黑屏问题

当前使用的Unity版本是2021.3.23f,在使用UMP进行监控视频流播放的时候出现黑屏的问题,参考了很多大佬的都没有解决这个问题,要不就是在自己电脑上无法播放,要不就是在自己电脑正常但是别人的电脑黑屏,后来改动了一下解决了这个问题

解决方法

1.UMP插件请使用2.0.3

2.如果你的电脑上安装了vlc播放器,打包后在自己的电脑使用ump播放是正常的,但是在没有vlc的电脑上就无法播放

首先找到ump插件下的Resources->UMPSettings取消勾选Use installed VLCUnity UMP打包黑屏问题_第1张图片

然后修改代码UniversalMediaPlayer->Editor->UMPPostBuilds中的BuildWindowsPlayer64函数

public static void BuildWindowsPlayer64(string path, UMPSettings settings)
{
    string buildPath = Path.GetDirectoryName(path);
    string dataPath = buildPath + "/" + Path.GetFileNameWithoutExtension(path) + "_Data";

    if (!string.IsNullOrEmpty(buildPath))
    {
        if (!settings.UseExternalLibraries)
        {
            CopyPlugins(settings.AssetPath + "/Plugins/Win/x86_64/plugins/", dataPath + "/Plugins/plugins/");
            // 复制 libvlc.dll 和 libvlccore.dll
            File.Copy(settings.AssetPath + "/Plugins/Win/x86_64/libvlc.dll", dataPath + "/Plugins/libvlc.dll", true);
            File.Copy(settings.AssetPath + "/Plugins/Win/x86_64/libvlccore.dll", dataPath + "/Plugins/libvlccore.dll", true);
            File.Copy(settings.AssetPath + "/Plugins/Win/x86_64/UniversalMediaPlayer.dll", dataPath + "/Plugins/UniversalMediaPlayer.dll", true);
            //修改代码
            string[] files = Directory.GetFiles(dataPath + "/Plugins/x86_64/");
            foreach (string str in files)
            {
                string file = Path.GetFileName(str);
                Debug.LogError(file);
                File.Copy(str, dataPath + "/Plugins/" + file);
            }
            Directory.Delete(dataPath + "/Plugins/x86_64/", true);

            

        }
        else
        {
            if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll"))
                File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll");

            if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll"))
                File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll");
        }
    }
    Debug.Log("Standalone Windows (x86_x64) build is completed: " + path);
}

最后要将该程序包放置纯英文路径下

参考文章https://blog.csdn.net/f402455894/article/details/125798362?login=from_csdn

你可能感兴趣的:(unity,游戏引擎)