我如何使用 vector3 数组在检查器中列出列表中的所有 vector3?

How i use array of vector3 to list in inspector all vector3 in list?

在脚本的顶部:

public Vector3[] positionsList;
List<Vector3> positions = new List<Vector3>();

在更新中:我正在更新列表,但我也想更新数组,这样我就可以在游戏 运行.

时在检查器中查看 vector3 位置
var position = GenerateRandomPositions(objects[0]);

        if (!positions.Contains(position))
        {
             positions.Add(position);
        }

只需制作Listpublic,检查员即可搞定

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ListInInspectorTest : MonoBehaviour {

    public List<Vector3> superawesomeListOfVector3s;

    void Update () {

        if(superawesomeListOfVector3s.Count < 10) {
            superawesomeListOfVector3s.Add(Random.insideUnitSphere);
        }

    }
}

如果变量对其他代码私有或受保护很重要。您可以在要在检查器中看到的变量上方添加 [SerializeField] 标记。来源 (https://unity3d.com/learn/tutorials/topics/tips/show-private-variables-inspector)