2017-10-17 64 views
0

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

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

在更新:我更新列表中,但我也想更新数组,所以我可以在游戏运行过程中,检查人员看的Vector3位置。

var position = GenerateRandomPositions(objects[0]); 

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

你的问题是什么? – Programmer

回答

0

只要公开清单,检查员就可以处理它。

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); 
     } 

    } 
}