シンプルに1pxの線を描く line rendererを使わず、の方法。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Lines : MonoBehaviour { [SerializeField] private MeshFilter _meshFilter; private Vector3[] _positions; private Mesh _mesh; // Start is called before the first frame update void Start() { _mesh = new Mesh(); _positions = new Vector3[100]; int[] indices = new int[100]; for(int i=0;i<100;i++){ _positions[i] = new Vector3( 10f * (Random.value-0.5f), 10f * (Random.value-0.5f), 10f * (Random.value-0.5f) ); indices[i] = i; } _mesh.vertices = _positions; _meshFilter.mesh = _mesh; _mesh.SetIndices(indices, MeshTopology.Lines, 0); } // Update is called once per frame void Update() { for(int i=0;i<_positions.Length;i++){ if(i%2==0){ _positions[i]=Vector3.zero; }else{ _positions[i] = new Vector3( 10f * (Random.value-0.5f), 10f * (Random.value-0.5f), 10f * (Random.value-0.5f) ); } } _mesh.vertices = _positions; } }