アセット
ソースコード
using System.Collections.Generic; using UnityEngine; using Vectrosity; public class Test : MonoBehaviour { public float m_size; public Color m_color = Color.white; public float m_lineWidth; public float m_offset; public float m_angle; private VectorLine m_line; private List<Vector2> m_points = new List<Vector2>( 5 ); private void Start() { m_line = new VectorLine ( name : "line", points : m_points, width : m_size, lineType : LineType.Continuous ); } private void Update() { var rad1 = ( m_angle + 0 ) * Mathf.Deg2Rad; var rad2 = ( m_angle + 90 ) * Mathf.Deg2Rad; var rad3 = ( m_angle + 180 ) * Mathf.Deg2Rad; var rad4 = ( m_angle + 270 ) * Mathf.Deg2Rad; var topLeft = new Vector3( -m_offset * Mathf.Cos( rad1 ), -m_offset * Mathf.Sin( rad1 ) ); var topRight = new Vector3( -m_offset * Mathf.Cos( rad2 ), -m_offset * Mathf.Sin( rad2 ) ); var bottomRight = new Vector3( -m_offset * Mathf.Cos( rad3 ), -m_offset * Mathf.Sin( rad3 ) ); var bottomLeft = new Vector3( -m_offset * Mathf.Cos( rad4 ), -m_offset * Mathf.Sin( rad4 ) ); m_points[ 0 ] = topLeft ; m_points[ 1 ] = topRight ; m_points[ 2 ] = bottomRight ; m_points[ 3 ] = bottomLeft ; m_points[ 4 ] = topLeft ; m_line.color = m_color; m_line.lineWidth = m_lineWidth; m_line.Draw(); } }