Version: 2017.1
public static float Sign (float f);

描述

返回 f 的符号。

f 为正数或零时,返回值为 1,当 f 为负数时,返回值为 -1。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { Debug.Log(Mathf.Sign(-10)); Debug.Log(Mathf.Sign(10)); } }