Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ToString

Formats this vector as a string.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

ToString()

Formats this vector as a string.
public override string ToString()

Returns

Type

Description

stringA formatted string representation of this vector.

Remarks

Defaults to two digits displayed (format="F2"). For more information, see Microsoft's documentation on Standard numeric format strings.

Examples

using UnityEngine;public class Example : MonoBehaviour{ void Start() { Vector2 vector = new Vector2(1, 2); Debug.Log(vector.ToString()); // output displayed as: "(1.00, 2.00)" }}

ToString(string)

Formats this vector as a string, using a given numeric format.
public string ToString(string format)

Parameters

format

A numeric format string.

Returns

Type

Description

stringA formatted string representation of this vector.

ToString(string, IFormatProvider)

Formats this vector as a string, using a given numeric format and culture-specific formatting.
public string ToString(string format, IFormatProvider formatProvider)

Parameters

format

A numeric format string.

formatProvider

An object that specifies culture-specific formatting.

Returns

Type

Description

stringA formatted string representation of this vector.