Mathf.Sign 符号

static function Sign (f : float) : float

Description描述

Returns the sign of f.

返回 f 的符号。

Return value is 1 when f is positive or zero, -1 when f is negative.

当 f 为正或为0返回1,为负返回-1。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		Debug.Log(Mathf.Sign(-10));
		Debug.Log(Mathf.Sign(10));
	}
}
Debug.Log(Mathf.Sign(-10));
Debug.Log(Mathf.Sign(10));
Page last updated: 2011-2-23