C# 顶点数组太大。精灵网格的顶点不得超过65535个。统一

C# 顶点数组太大。精灵网格的顶点不得超过65535个。统一,c#,unity3d,svg,C#,Unity3d,Svg,我尝试在unity中使用svg文件 我在packagemanager中设置了vectorgraphics 2.00 但发生导入文件错误 我的SVG文件最大大小是2500亿和7mb的顶点 我知道网格最大顶点400亿,但我不知道精灵最大顶点 大尺寸1600kb图片 这不是结果 svg项目已被删除看起来您需要在导入之前简化正在导入的文件。@RobertLongson svg裁剪简单吗?如果剪切一个svg,在屏幕上显示不同的svg时,是否可以确保彼此位置之间的关系不会中断?不完全是这样。您可能会发现,像

我尝试在unity中使用svg文件

我在packagemanager中设置了vectorgraphics 2.00

但发生导入文件错误

我的SVG文件最大大小是2500亿和7mb的顶点

我知道网格最大顶点400亿,但我不知道精灵最大顶点

大尺寸1600kb图片

这不是结果


svg项目已被删除

看起来您需要在导入之前简化正在导入的文件。@RobertLongson svg裁剪简单吗?如果剪切一个svg,在屏幕上显示不同的svg时,是否可以确保彼此位置之间的关系不会中断?不完全是这样。您可能会发现,像Inkscape这样的SVG编辑器具有一些简化SVG文件的功能。切割和重新组装对于问答来说太广泛了,您需要尝试一下并提出更具体的问题。您可以将网格索引器格式更改为
UInt32
,最多允许
4294967295
,但您确实不应该开始使用反射。。。看起来总的来说,你应该走一条不同的路线,为什么不使用正确的超负荷?
Vertex array is too large. A sprite mesh may not have more than 65535 vertices.
UnityEngine.Sprite:OverrideGeometry(Vector2[], UInt16[])
Unity.VectorGraphics.VectorUtils:BuildSprite(List`1, Rect, Single, Alignment, Vector2, UInt16, Boolean) (at Library/PackageCache/com.unity.vectorgraphics@2.0.0-preview.12/Runtime/VectorSprite.cs:119)
Unity.VectorGraphics.Editor.SVGImporter:BuildSpriteFromGeometry(List`1, Rect) (at Library/PackageCache/com.unity.vectorgraphics@2.0.0-preview.12/Editor/SVGImporter.cs:344)
Unity.VectorGraphics.Editor.SVGImporter:OnImportAsset(AssetImportContext) (at Library/PackageCache/com.unity.vectorgraphics@2.0.0-preview.12/Editor/SVGImporter.cs:317)
UnityEditor.Experimental.AssetImporters.ScriptedImporter:GenerateAssetData(AssetImportContext)
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

 public static Sprite BuildSprite(List<Geometry> geoms, Rect rect, float svgPixelsPerUnit, Alignment alignment, Vector2 customPivot, UInt16 gradientResolution, bool flipYAxis = false)
    {
        // Generate atlas
        var texAtlas = GenerateAtlasAndFillUVs(geoms, gradientResolution);

        List<Vector2> vertices;
        List<UInt16> indices;
        List<Color> colors;
        List<Vector2> uvs;
        List<Vector2> settingIndices;
        FillVertexChannels(geoms, 1.0f, texAtlas != null, out vertices, out indices, out colors, out uvs, out settingIndices, flipYAxis);

        Texture2D texture = texAtlas != null ? texAtlas.Texture : null;

        if (rect == Rect.zero)
        {
            rect = VectorUtils.Bounds(vertices);
            VectorUtils.RealignVerticesInBounds(vertices, rect, flipYAxis);
        }
        else if (flipYAxis)
        {
            VectorUtils.FlipVerticesInBounds(vertices, rect);

            // The provided rect should normally contain the whole geometry, but since VectorUtils.SceneNodeBounds doesn't
            // take the strokes into account, some triangles may appear outside the rect. We clamp the vertices as a workaround for now.
            VectorUtils.ClampVerticesInBounds(vertices, rect);
        }

        var pivot = GetPivot(alignment, customPivot, rect, flipYAxis);

        // The Sprite.Create(Rect, Vector2, float, Texture2D) method is internal. Using reflection
        // until it becomes public.
        var spriteCreateMethod = typeof(Sprite).GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic, Type.DefaultBinder, new Type[] { typeof(Rect), typeof(Vector2), typeof(float), typeof(Texture2D) }, null);
      //it is error part
                    //it is error part  
            sprite.OverrideGeometry(vertices.ToArray(), indices.ToArray());