PlayerPrefs.GetInt 获取整数键值

static function GetInt (key : string, defaultValue : int = 0) : int

Description描述

Returns the value corresponding to key in the preference file if it exists.

如果存在,返回游戏存档文件中key对应的值。

If it doesn't exist, it will return defaultValue.

如果不存在,将返回默认值。

using UnityEngine;

using System.Collections;



public class example : MonoBehaviour {

	public void Awake() {

		print(PlayerPrefs.GetInt("Player Score"));

	}

}
print (PlayerPrefs.GetInt("Player Score"));
Page last updated: 2012-5-27