我试图在运行时将 .svg
文件转换为光栅图像 (.png),以便在我的 Unity 程序中在 Android 上呈现它:)
我找到的最佳解决方案是使用这个 lib
不过,我添加了 .Dll
(称为“Svg”)和这段小代码:
Svg.SvgDocument doc = Svg.SvgDocument.Open(filename);
通过这一行,Unity 告诉我:
Unhandled Exception: System.TypeLoadException: Could not load type 'Svg.SvgElement' from assembly 'Svg, Version=0.5.2.0, Culture=neutral, PublicKeyToken=null'.
at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)
at System.MonoType.GetMethods (BindingFlags bindingAttr) [0x00000] in :0
etc...
我猜这是 DLL 使用/导入问题?我不太习惯在 Unity 中使用 DLL/插件...我在这里问这个问题,因为我在网上找不到任何东西:/
你有在 unity android 上绘制我的 .svg 的正确方法吗?
最佳答案
您可以使用此插件在构建时将 SVG 转换为 PNG,因此您的应用程序仅依赖于各种密度的 PNG:https://github.com/avianey/androidsvgdrawable-plugin
它与 gradle 构建系统(以及 maven 系统)集成
关于c# - Android 上的 Unity .SVG 到 .PNG 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32272315/