ソースコード
using UnityEngine; public static class Vector2Ext { public static Vector2 Round( this Vector2 self ) { return new Vector2 ( Mathf.Round( self.x ), Mathf.Round( self.y ) ); } }
使い方
var vec = new Vector2( 1.1f, 1.1f ); vec = vec.Round();
using UnityEngine; public static class Vector2Ext { public static Vector2 Round( this Vector2 self ) { return new Vector2 ( Mathf.Round( self.x ), Mathf.Round( self.y ) ); } }
var vec = new Vector2( 1.1f, 1.1f ); vec = vec.Round();