コガネブログ

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

【Unity】Unity 2023.1 新機能 - Gizmos.DrawLineList・Gizmos.DrawLineStrip が追加された

これまで

using UnityEngine;

public sealed class Example : MonoBehaviour
{
    private void OnDrawGizmos()
    {
        Gizmos.DrawLine( new( 0, 0 ), new( 1, 0 ) );
        Gizmos.DrawLine( new( 1, 0 ), new( 1, 1 ) );
        Gizmos.DrawLine( new( 1, 1 ), new( 0, 1 ) );
        Gizmos.DrawLine( new( 0, 1 ), new( 0, 0 ) );
    }
}

新機能

using UnityEngine;

public sealed class Example : MonoBehaviour
{
    private void OnDrawGizmos()
    {
        var points = new Vector3[]
        {
            new( 0, 0 ),
            new( 1, 0 ),
            new( 1, 0 ),
            new( 1, 1 ),
            new( 1, 1 ),
            new( 0, 1 ),
            new( 0, 1 ),
            new( 0, 0 ),
        };

        Gizmos.DrawLineList( points );
    }
}
using UnityEngine;

public sealed class Example : MonoBehaviour
{
    private void OnDrawGizmos()
    {
        var points = new Vector3[]
        {
            new( 0, 0 ),
            new( 1, 0 ),
            new( 1, 1 ),
            new( 0, 1 ),
        };

        Gizmos.DrawLineStrip( points, true );
    }
}

参考サイト様