Cr Development notes-6 user data storage

Source: Internet
Author: User

Still post code

Using unityengine; using system. collections; public class datecontrol: monobehaviour {public static string name; public static int num; bool jbstart; float fullwidth; float fullheight; rect fullscreen; // window rect nametext; rect gobtn; rect pointout; bool jblb; // used to display the prompt text // use this for initialization // static method public static int getnum () {return playerprefs. getint ("_ num");} public static string getnam E () {return playerprefs. getstring ("_ name");} void start () {jblb = true; fullheight = screen. height; fullwidth = screen. width; jbstart = false; nametext = new rect (fullwidth/10) * 3, (fullheight/10) * 4, (fullwidth/10) * 4, (fullheight/10) * 2); gobtn = new rect (fullwidth/10) * 3, (fullheight/10) * 6, (fullwidth/10) * 4, (fullheight/10) * 2); fullscreen = new rect (0, 0, screen. Width, screen. height); pointout = new rect (fullwidth/10) * 3, (fullheight/10) * 3, (fullwidth/10) * 4, (fullheight/10) * 1); If (playerprefs. haskey ("_ name") // judge whether there is a name {// load data name = playerprefs. getstring ("_ name"); num = playerprefs. getint ("_ num"); this. gameobject. addcomponent ("startmenu"); //} else {// initialize data name = ""; num = 0; jbstart = true; playerprefs. setstring ("_ name", name); PLA Yerprefs. setint ("_ num", num) ;}// update is called once per frame void Update () {}void winstart (INT winid) {If (jblb) {GUI. label (pointout, "enter your name");} else {GUI. label (pointout, "invalid name");} name = GUI. textfield (nametext, name, 20); If (GUI. button (gobtn, "OK") {If (! (Name. equals ("") {playerprefs. setstring ("_ name", name); jbstart = false; this. gameobject. addcomponent ("startmenu") ;}else {jblb = false ;}} void ongui () {If (jbstart) {GUI. window (0, fullscreen, winstart, "Trip ");}}}

Today, I read and read the data.

Where is the data storage location?

On Mac OS X playerprefs are stored in ~ /Library/preferences folder, in a file named unity. [company name]. [product name]. plist, where company and product names are the names set up in Project Settings. the same. plist file is used for both projects run in the editor and standalone players.

Playerprefs on Mac OS X is stored in ~ /Library/playerprefs folder named unity. [company name]. [product name]. plist. Here, the company and product names are set in project setting. The same plist is used for the project and independent mode running in the editor.

On Windows standalone players, playerprefs are stored in the registry under hkcu \ Software \ [company name] \ [product name] key, where company and product names are the names set up in Project Settings.

In Windows standalone mode, playerprefs is stored under the hkcu \ Software \ [company name] \ [product name] Key of the Registry, here, company and product names are set in project setting.

On Web players, playerprefs are stored in binary files under ~ /Library/preferences/Unity/webplayerprefs on Mac OS X and % appdata % \ unity \ webplayerprefs on Windows. there is one preference file per web Player URL and the file size is limited to 1 megabyte. if this limit wocould be exceeded, setint, setfloat and setstring will not store the value and throw a playerprefsexception.

In Web mode, playerprefs is stored in the binary file of Mac OS X ~ In/library/preferences/Unity/webplayerprefs and % appdata % \ unity \ webplayerprefs of windows, a game archive file corresponds to a web Player URL and the file size is limited to 1 MB. If this limit is exceeded, setint, setfloat, and setstring do not store values and throw a playerprefsexception.

From unity

 

The next step is guiskin and aircraft control.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.