LoginSignup
0
0

More than 1 year has passed since last update.

Unity LineRenderer SetPositions 同じ頂点 入らない

Posted at

状況

スクリプトから、LineRenedererコンポーネントのPositionsにSetPositions()を使って複数の値を入れようとしてるのに、2つまでしか入らない!!!
おかしいだろ!!!

TestLineRenderer.cs
Vector3[] array = new Vector3[5]{Vector3.zero,Vector3.one,Vector3.zero,Vector3.one};
_lineRenderer.SetPositions(array);

※このコードはイメージです

image.png

SetPositionsに流し込む値は5個あるのに2個しか入らない・・・

VisualStudioにブレークポイント張ってLineRendererの中身見ても同じ・・・2個までしか入ってない・・・

解決策

SetPositions()を行う前に,positionCountの値を変えたらいけます!!!!

TestLineRenderer.cs
Vector3[] array = new Vector3[5]{Vector3.zero,Vector3.one,Vector3.zero,Vector3.one};

//ここを追加や!!
_lineRenderer.positionCount = array.Length;

_lineRenderer.SetPositions(array);

※このコードはイメージです

原因

positionCountの値がSetPositionsで入れることができる最大の値だそうです!!!
それ以上はァ!!すべてェ!!!無視されます!(無慈悲)

そしてなんとこれはUnity公式のリファレンスに書いてあります!!!

見てないやつおる!?!?!いねぇよなぁ???!!
ここにおるでw

はい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0