小编lan*_*ngs的帖子

如何在Unity 2018.1中使用具有超过64k顶点的网格

我听说Unity现在支持32位索引缓冲区.但是,当我尝试使用Unity 2018.1时,我无法使其工作.

我用这样的代码构建了网格:

    int nVertices = nx * ny;
    Vector3[] vertices = new Vector3[nVertices];
    Color[] colors = new Color[nVertices];
    for(int i = 0; i < nx; i++) {
        float x = i * w / (nx - 1);
        for (int j = 0; j < ny; j++) {
            float y = j * h / (ny - 1);
            int vindex = i * ny + j;
            vertices[vindex] = new Vector3(x, y, 0);
            float colorx = Mathf.Sin(x) / 2 + 0.5f; …
Run Code Online (Sandbox Code Playgroud)

c# rendering unity-game-engine

9
推荐指数
1
解决办法
4910
查看次数

关键字 `in, out, ref` 与属性 `[In], [Out], [In, Out]`

我知道第一组关键字in, out, ref可以在所有 C# 函数中使用,第二组属性[In], [Out], [In, Out]用于 marshaller。

我不确定它们在本机代码的函数声明中使用时是否表示相同的意思。例如,以下两个声明是否等效?

[DllImport("xxx.dll")]
void FillArray1(ref int[] arr, in int length);

[DllImport("xxx.dll")]
void FillArray2([In, Out] int[] arr, [In] int length);
Run Code Online (Sandbox Code Playgroud)

是否存在两个集合不等价的情况?

c# marshalling

7
推荐指数
1
解决办法
996
查看次数

从C ++本机插件更新Vector3数组

Marshal.Copy()方法仅支持几种数组类型。现在我只知道如何从IntPtr(指向C ++代码中的float数组)复制到float[]

IntPtr pvertices = GetVerticesFromCPP();
float[] vertices = new float[nVertices * 3];
Marshal.Copy(pvertices, vertices, 0, nVertices * 3);
Run Code Online (Sandbox Code Playgroud)

但是我真正想要的是一个UnityEngine.Vector3[]

我需要手动转换float[]UnityEngine.Vector3[]吗?还是有一种更简单,更快捷的方法直接做到这一点?

c# c++ marshalling unity-game-engine

3
推荐指数
1
解决办法
776
查看次数

如何在 Unity 中渲染流线?

我想在 Unity 中渲染流线。流线是许多空间曲线,每个顶点都有自己的颜色。像下图:

在此处输入图片说明

Unity 的 LineRenderer 似乎无法为单个节点分配颜色。所以我该怎么做?

unity-game-engine

0
推荐指数
1
解决办法
829
查看次数

标签 统计

c# ×3

unity-game-engine ×3

marshalling ×2

c++ ×1

rendering ×1