public static void ClearAll(bool prompt) { if (!prompt || EditorUtility.DisplayDialog("Clear Editor Prefs", "Delete all the editor preferences?", "Yes", "No")) { PlayerPref.ClearAll(); } }
/// <summary> /// /// </summary> public void ResetGame() { playerPref = new PlayerPref(); save(); soundButton.GetComponent <Image>().sprite = normalSound; Awake(); }
// Start is called before the first frame update void Start() { #region PlayerPref if (PlayerPref.kolayDegerOku() == 1) { carpan1 = 0.7f; carpan2 = 1.3f; canEklemeZamanı = 10; virüsÜretmeZamanı = 2.4f; } if (PlayerPref.ortaDegerOku() == 1) { carpan1 = 0.9f; carpan2 = 1.5f; canEklemeZamanı = 12; virüsÜretmeZamanı = 2.2f; } if (PlayerPref.zorDegerOku() == 1) { carpan1 = 1.1f; carpan2 = 1.8f; canEklemeZamanı = 14; virüsÜretmeZamanı = 2f; } #endregion Puan = 0; ekran_Hesaplama = cadde1.GetComponent <Ekran_Hesaplama>(); camKonum = Camera.main.transform.position; cadde1.transform.position = new Vector2(camKonum.x, camKonum.y); cadde2.transform.position = new Vector2(camKonum.x + ekran_Hesaplama.EkranGenislik, camKonum.y); oyunBalangıcı(); }
// Use this for initialization void Start() { //Set all panels to Hide until we need them StoryPanel.SetActive(false); LevelPanel.SetActive(false); ChallengePanel.SetActive(false); AccountPanel.SetActive(false); //Logout Button Logout.onClick.AddListener(LogOut); //Linking and unlinking device LinkButton.onClick.AddListener(LinkAndUnlink); //Opening and closing account panel AccountButton.onClick.AddListener(OpenAccount); CloseButton.onClick.AddListener(CloseAccount); ClearButton.onClick.AddListener(ClearData); //Story mode StoryButton.onClick.AddListener(Storymode); LevelButton.onClick.AddListener(Levelmode); ChallengeButton.onClick.AddListener(Challengemode); //Credit page CreditButton.gameObject.SetActive(true); CreditButton.onClick.AddListener(GoToCredit); //Subscribe to events that happen after we get data PlayFabService.DataResult += DataResult; pf = new PlayerPref(); //Remove Some UI for WebGL if (Application.platform == RuntimePlatform.WebGLPlayer) { Logout.gameObject.SetActive(false); LinkButton.gameObject.SetActive(false); Title.gameObject.SetActive(false); } }
public static void Save(string name, object o) { Type t = o.GetType(); FieldInfo[] fiedls = t.GetFields(); for (int i = 0; i < fiedls.Length; i++) { string saveName = name + "." + fiedls[i].Name; switch (fiedls[i].FieldType.Name) { case "String": PlayerPref.SetString(saveName, fiedls[i].GetValue(o).ToString()); break; case "Int32": case "Int64": case "Int": case "uInt": PlayerPref.SetInt(saveName, (int)fiedls[i].GetValue(o)); break; case "Float": PlayerPref.SetFloat(saveName, (float)fiedls[i].GetValue(o)); break; } } }
public static void LoadCvar(Cvar data) { if (Console.Get().configFile != "") { return; } if (PlayerPref.Has(data.fullName)) { object value = data.value.Get(); Type type = data.value.type; if (type == typeof(float)) { value = PlayerPref.Get <float>(data.fullName); } else if (type == typeof(string)) { value = PlayerPref.Get <string>(data.fullName); } else if (type == typeof(int) || type == typeof(byte)) { value = PlayerPref.Get <int>(data.fullName); } else if (type == typeof(bool)) { value = PlayerPref.Get <int>(data.fullName) == 1 ? true : false; } data.value.Set(value); } }
public void UpdateEffects() { #if UNITY_EDITOR var updateShaders = PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateShaders"); var updateParticles = PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateParticles"); if (updateShaders) { Shader.SetGlobalFloat("timeConstant", Time.Get()); } foreach (var system in Locate.GetSceneComponents <ParticleSystem>()) { if (system.IsNull()) { continue; } var updater = system.gameObject.GetComponent <UpdateParticle>(); if (updateParticles && updater.IsNull()) { updater = system.gameObject.AddComponent <UpdateParticle>(); updater.hideFlags = HideFlags.DontSaveInBuild | HideFlags.NotEditable | HideFlags.HideInInspector; } if (!updateParticles && !updater.IsNull()) { DestroyImmediate(updater); } } if (updateShaders || updateParticles) { ProxyEditor.RepaintSceneView(); } #endif }
public static T GetValue <T>(string name) where T : new() { T newObj = new T(); Type t = newObj.GetType(); FieldInfo[] fiedls = t.GetFields(); for (int i = 0; i < fiedls.Length; i++) { string saveName = name + "." + fiedls[i].Name; switch (fiedls[i].FieldType.Name) { case "String": fiedls[i].SetValue(newObj, PlayerPref.GetString(saveName)); break; case "Int32": case "Int64": case "Int": case "uInt": fiedls[i].SetValue(newObj, PlayerPref.GetInt(saveName)); break; case "Float": fiedls[i].SetValue(newObj, PlayerPref.GetFloat(saveName)); break; } } return(newObj); }
private void Awake() { if (instance == null) { instance = this; } }
private void buttonInSelect_Click(object sender, EventArgs e) { if (IsFolder) { FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); folderBrowserDialog1.Description = "请选择文件夹路径"; folderBrowserDialog1.ShowNewFolderButton = false; folderBrowserDialog1.SelectedPath = InputPath; DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { string folderName = folderBrowserDialog1.SelectedPath; if (folderName != "") { textBoxInput.Text = folderName; } } } else { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = false; fileDialog.Title = "请选择文件"; fileDialog.FileName = PlayerPref.GetData("Md5VersionSingle_Input"); fileDialog.Filter = "所有 文件(*.*)|*.*"; if (fileDialog.ShowDialog() == DialogResult.OK) { textBoxInput.Text = fileDialog.FileName; } } }
public static void LoadBinds() { Console.AddBind("BackQuote", "console"); if (Console.Get().configFile != "") { return; } if (!PlayerPref.Has("binds")) { PlayerPref.Set <string>("binds", "|"); } string binds = PlayerPref.Get <string>("binds"); string[] bindList = binds.Split('|'); foreach (string item in bindList) { string[] dataList = item.Split('-'); if (dataList.Length < 3) { continue; } string key = dataList[1]; string action = dataList[2]; bool toggle = dataList[0] == "toggle"; bool repeat = dataList[0] == "repeat"; float repeatDelay = dataList.Length > 3 ? Convert.ToSingle(dataList[3]) : 0; Console.AddBind(key, action, toggle, repeat, repeatDelay); } }
public static float GetFloat(string key, float defaultValue = 0f) { string @string = PlayerPref.GetString(key, defaultValue.ToString()); float result = defaultValue; float.TryParse(@string, out result); return(result); }
public static int GetInt(string key, int defaultValue = 0) { string @string = PlayerPref.GetString(key, defaultValue.ToString()); int result = defaultValue; int.TryParse(@string, out result); return(result); }
public override void Load() { string path = this.value.info.fullPath; this.value.x = PlayerPref.Get <float>(path + "x"); this.value.y = PlayerPref.Get <float>(path + "y"); this.value.z = PlayerPref.Get <float>(path + "z"); }
public override void Store() { string path = this.value.info.fullPath; PlayerPref.Set <float>(path + "x", this.value.x); PlayerPref.Set <float>(path + "y", this.value.y); PlayerPref.Set <float>(path + "z", this.value.z); }
public void Zor() { PlayerPref.kolayDegerAta(0); PlayerPref.ortaDegerAta(0); PlayerPref.zorDegerAta(1); kolay.interactable = true; orta.interactable = true; zor.interactable = false; }
// Start is called before the first frame update void Start() { puan1 = PlayerPref.puan1rOku(); puan2 = PlayerPref.puan2rOku(); puan3 = PlayerPref.puan3Oku(); Puan1.text = "1:) " + puan1.ToString(); Puan2.text = "2:) " + puan2.ToString(); Puan3.text = "3:) " + puan3.ToString(); }
public static string GetString(string key, string defaultValue = "") { string text = defaultValue; string @string = PlayerPrefs.GetString(PlayerPref.GetHash(key), defaultValue.ToString()); if (!text.Equals(@string)) { text = PlayerPref.Decrypt(@string); } return(text); }
private void Init() { if (IsFolder) { labelInput.Text = "资源文件夹路径:"; InputPath = PlayerPref.GetData(VersionFolderInput); OutPutPath = PlayerPref.GetData(VersionFolderOutput); } else { labelInput.Text = "资源文件路径:"; InputPath = PlayerPref.GetData(VersionSingleInput); OutPutPath = PlayerPref.GetData(VersionSingleOutput); } BigVersionNum = PlayerPref.GetData(VersionBigVersionNum); VerType = PlayerPref.GetData(VersionType); TarType = PlayerPref.GetData(TargetType); IgnoorePostFix = PlayerPref.GetData(VersionIgnorePostFix); textBoxInput.Text = InputPath; textBoxOutPut.Text = OutPutPath; textBoxBigVersionNum.Text = BigVersionNum; textBoxIgnoreFileName.Text = IgnoorePostFix; switch (VerType) { case "Num": radioButtonNum.Checked = true; break; default: radioButtonMd5.Checked = true; break; } switch (TarType) { case "Upper": radioButtonUpper.Checked = true; break; default: radioButtonLower.Checked = true; break; } SizeUnit = PlayerPref.GetData(VersionFileSizeUnit, "B"); for (int i = 0; i < cbUnit.Items.Count; i++) { if (cbUnit.Items[i].ToString() == SizeUnit) { cbUnit.SelectedIndex = i; break; } } buttonSave.Enabled = false; }
private void LoadPlayerPref() { playerPref = new PlayerPref(); //Stores and accesses player preferences between game sessions. // HasKey Returns true if key exists in the preferences. if (PlayerPrefs.HasKey("audioMode")) { // get audioMode form PlayePrefs and store in playerPref.audioMode playerPref.audioMode = PlayerPrefs.GetInt("audioMode"); } }
void Awake() { if(current != null && current != this) { Destroy(gameObject); } else { DontDestroyOnLoad(gameObject); current = this; } }
public static void ResetCvars(string[] values) { string binds = PlayerPref.Get <string>("binds"); PlayerPref.ClearAll(); PlayerPref.Set <string>("binds", binds); foreach (var item in Console.cvars) { Cvar data = item.Value; data.value.Set(data.defaultValue); } Console.AddLog("^10All stored ^3cvars^10 have been reset to default values."); }
bool TryGetPlayerPref(string key, out PlayerPref playerPref) { playerPref = null; for (int i = 0; i < playerPrefs.Count; i++) { if (playerPrefs[i].key == key) { playerPref = playerPrefs[i]; return(true); } } return(false); }
void Start() { Time.timeScale = 1; if (!PlayerPref.ZorlukDegerKontrol()) { PlayerPref.ortaDegerAta(1); } //Debug.Log("aa"+PlayerPref.Puanlar.Count); if (PlayerPref.Puanlar.Count < 1) { PlayerPref.Puanlar.Add(PlayerPref.puan1rOku()); PlayerPref.Puanlar.Add(PlayerPref.puan2rOku()); PlayerPref.Puanlar.Add(PlayerPref.puan3Oku()); } }
void muteButtonClick() { if (PlayerPrefs.GetInt("playerMute")) { // If 1 (on) // Set sound off PlayerPref.SetInt("playerMute", 0); } else { // It's 0 (off) // Set sound on PlayerPrefs.SetInt("playerMute", 1); } }
public void OnWillRenderObject() { if (Proxy.IsEditor() && !Proxy.IsPlaying() && Camera.current != null) { if (PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateParticles")) { float range = PlayerPref.Get <float>("EditorSettings-ParticleUpdateRange"); Vector3 cameraPosition = Camera.current.transform.position; Vector3 objectPosition = this.transform.position; if (Vector3.Distance(cameraPosition, objectPosition) <= range) { this.GetComponent <ParticleSystem>().Simulate(Time.Get() % 60 + 10); } } } }
private void buttonOutSelect_Click(object sender, EventArgs e) { FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); folderBrowserDialog1.Description = "请选择生成的文件路径"; folderBrowserDialog1.SelectedPath = PlayerPref.GetData("Md5VersionSingle_Output"); folderBrowserDialog1.ShowNewFolderButton = false; DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { string folderName = folderBrowserDialog1.SelectedPath; if (folderName != "") { textBoxOutPut.Text = folderName; } } }
public void Test() { User user = new User(); user.Name = "哈哈哈"; user.Age = 122; user.Describe = "test "; user.dse = "text"; user.text = "text"; PlayerPref.Save("user", user); user = null; user = PlayerPref.GetValue <User>("user"); Debug.Log("user name: " + user.Name); Debug.Log("user Age: " + user.Age); Debug.Log("user Describe: " + user.Describe); }
/// <summary> /// Load game data (Player Pref) /// </summary> public void load() { string data = PlayerPrefs.GetString(PLAYER_KEY); if (data == null || data.Length == 0) { playerPref = new PlayerPref(); } else { BinaryFormatter bf = new BinaryFormatter(); byte[] b = Convert.FromBase64String(data); MemoryStream ms = new MemoryStream(b); try { playerPref = (PlayerPref)bf.Deserialize(ms); } finally { ms.Close(); } } }
// Start is called before the first frame update void Start() { if (PlayerPref.kolayDegerOku() == 1) { kolay.interactable = false; orta.interactable = true; zor.interactable = true; } if (PlayerPref.ortaDegerOku() == 1) { kolay.interactable = true; orta.interactable = false; zor.interactable = true; } if (PlayerPref.zorDegerOku() == 1) { kolay.interactable = true; orta.interactable = true; zor.interactable = false; } }
// Use this for initialization private void Start() { is_bunny_moving_ = false; are_loop_commands_finished_ = false; executing_loop_ = false; hit_a_rock_ = false; win_ = false; next_command_name_ = ""; error_message_ = "Oops! Wrong commands!"; if (SceneManager.GetActiveScene().name.Contains("Challenge")) { is_challenge_level_ = true; } else { is_challenge_level_ = false; } execute_function_calls_ = new Stack <bool>(); list_of_commands_ = new List <GameObject>(); Win.text = ""; speed_ = 3; Beginning_ = GameObject.FindGameObjectWithTag("Respawn"); PlayerCommands_ = GameObject.FindGameObjectWithTag("Player Commands"); if (is_challenge_level_ == true) { score_ = GameObject.FindGameObjectWithTag("Score"); } else { score_ = null; } anim = GetComponent <Animator>(); level_ = SceneManager.GetSceneAt(SceneManager.sceneCount - 1).name; pf_ = new PlayerPref(); }