Version: 2023.2
言語: 日本語
public static float GetFloat (string key);
public static float GetFloat (string key, float defaultValue);

説明

キーが存在する場合、key に対応する値を取得します。

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

//Use this script to fetch the PlayerPrefs settings and show them as text on the screen.

using UnityEngine; using UnityEngine.UI;

public class PlayerPrefsDeleteAllExample : MonoBehaviour { float m_Health;

void Start() { //Fetch the PlayerPref settings SetText(); }

void SetText() { //Fetch the health from the PlayerPrefs (set these PlayerPrefs elsewhere). If no float of this name exists, the default is 0 m_Health = PlayerPrefs.GetFloat("Health", 0); }

void OnGUI() { //Fetch the PlayerPrefs settings and output them to the screen using Labels GUI.Label(new Rect(50, 90, 200, 30), "Health : " + m_Health); } }