2017-10-17 63 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); 
     } 

    } 
}