Unity UMP打包黑屏问题总结

我当前使用的Unity版本是2019.4.16f,在使用UMP进行监控视频流播放的时候出现黑屏的问题。总结一下解决问题的办法。

问题一:UMP插件版本问题

一开始我使用的是2.0.2版本的UMP发现这个版本在2019的unity中存在很多的问题,原本可以在Resources->UMPSettings配置相关的路径,但是这个版本并不可以。所以请使用2.0.2版本以上的插件。

第二个问题 :dll的文件路径问题

此是你会发现,打包后在你自己的电脑上播放时没有问题的,但是把包发给同事还是会出现黑屏的问题。因为你得VLC是一个绝对路径,在他人的电脑上是肯定找不到的。

1.取消勾选Use installed VLC

 2.修改代码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/");
                //修改代码
                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);
    }

问题三:64位问题

打包的时候请打64位的包。

猜你喜欢

转载自blog.csdn.net/f402455894/article/details/125798362
今日推荐