コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】LineRendererの頂点をVector3型の配列やリストで一括で設定できる拡張メソッド

using UnityEngine;

public static class LineRendererExtensions
{
    public static void SetPositions( this LineRenderer self, IList<Vector3> positions )
    {
        self.SetVertexCount( positions.Count );

        for ( int i = 0; i < positions.Count; i++ )
        {
            self.SetPosition( i, positions[ i ] );
        }
    }
}