Skip to content

Commit 6434cda

Browse files
committed
[李瑞瑞]本地存储
1 parent 9f48763 commit 6434cda

File tree

6 files changed

+381
-0
lines changed

6 files changed

+381
-0
lines changed
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!29 &1
4+
OcclusionCullingSettings:
5+
m_ObjectHideFlags: 0
6+
serializedVersion: 2
7+
m_OcclusionBakeSettings:
8+
smallestOccluder: 5
9+
smallestHole: 0.25
10+
backfaceThreshold: 100
11+
m_SceneGUID: 00000000000000000000000000000000
12+
m_OcclusionCullingData: {fileID: 0}
13+
--- !u!104 &2
14+
RenderSettings:
15+
m_ObjectHideFlags: 0
16+
serializedVersion: 9
17+
m_Fog: 0
18+
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19+
m_FogMode: 3
20+
m_FogDensity: 0.01
21+
m_LinearFogStart: 0
22+
m_LinearFogEnd: 300
23+
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24+
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25+
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26+
m_AmbientIntensity: 1
27+
m_AmbientMode: 0
28+
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29+
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
30+
m_HaloStrength: 0.5
31+
m_FlareStrength: 1
32+
m_FlareFadeSpeed: 3
33+
m_HaloTexture: {fileID: 0}
34+
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35+
m_DefaultReflectionMode: 0
36+
m_DefaultReflectionResolution: 128
37+
m_ReflectionBounces: 1
38+
m_ReflectionIntensity: 1
39+
m_CustomReflection: {fileID: 0}
40+
m_Sun: {fileID: 0}
41+
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
42+
m_UseRadianceAmbientProbe: 0
43+
--- !u!157 &3
44+
LightmapSettings:
45+
m_ObjectHideFlags: 0
46+
serializedVersion: 11
47+
m_GIWorkflowMode: 0
48+
m_GISettings:
49+
serializedVersion: 2
50+
m_BounceScale: 1
51+
m_IndirectOutputScale: 1
52+
m_AlbedoBoost: 1
53+
m_EnvironmentLightingMode: 0
54+
m_EnableBakedLightmaps: 1
55+
m_EnableRealtimeLightmaps: 1
56+
m_LightmapEditorSettings:
57+
serializedVersion: 10
58+
m_Resolution: 2
59+
m_BakeResolution: 40
60+
m_AtlasSize: 1024
61+
m_AO: 0
62+
m_AOMaxDistance: 1
63+
m_CompAOExponent: 1
64+
m_CompAOExponentDirect: 0
65+
m_Padding: 2
66+
m_LightmapParameters: {fileID: 0}
67+
m_LightmapsBakeMode: 1
68+
m_TextureCompression: 1
69+
m_FinalGather: 0
70+
m_FinalGatherFiltering: 1
71+
m_FinalGatherRayCount: 256
72+
m_ReflectionCompression: 2
73+
m_MixedBakeMode: 2
74+
m_BakeBackend: 1
75+
m_PVRSampling: 1
76+
m_PVRDirectSampleCount: 32
77+
m_PVRSampleCount: 500
78+
m_PVRBounces: 2
79+
m_PVRFilterTypeDirect: 0
80+
m_PVRFilterTypeIndirect: 0
81+
m_PVRFilterTypeAO: 0
82+
m_PVRFilteringMode: 1
83+
m_PVRCulling: 1
84+
m_PVRFilteringGaussRadiusDirect: 1
85+
m_PVRFilteringGaussRadiusIndirect: 5
86+
m_PVRFilteringGaussRadiusAO: 2
87+
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
88+
m_PVRFilteringAtrousPositionSigmaIndirect: 2
89+
m_PVRFilteringAtrousPositionSigmaAO: 1
90+
m_ShowResolutionOverlay: 1
91+
m_LightingDataAsset: {fileID: 0}
92+
m_UseShadowmask: 1
93+
--- !u!196 &4
94+
NavMeshSettings:
95+
serializedVersion: 2
96+
m_ObjectHideFlags: 0
97+
m_BuildSettings:
98+
serializedVersion: 2
99+
agentTypeID: 0
100+
agentRadius: 0.5
101+
agentHeight: 2
102+
agentSlope: 45
103+
agentClimb: 0.4
104+
ledgeDropHeight: 0
105+
maxJumpAcrossDistance: 0
106+
minRegionArea: 2
107+
manualCellSize: 0
108+
cellSize: 0.16666667
109+
manualTileSize: 0
110+
tileSize: 256
111+
accuratePlacement: 0
112+
debug:
113+
m_Flags: 0
114+
m_NavMeshData: {fileID: 0}
115+
--- !u!1 &1032722984
116+
GameObject:
117+
m_ObjectHideFlags: 0
118+
m_CorrespondingSourceObject: {fileID: 0}
119+
m_PrefabInstance: {fileID: 0}
120+
m_PrefabAsset: {fileID: 0}
121+
serializedVersion: 6
122+
m_Component:
123+
- component: {fileID: 1032722987}
124+
- component: {fileID: 1032722986}
125+
- component: {fileID: 1032722985}
126+
m_Layer: 0
127+
m_Name: Main Camera
128+
m_TagString: MainCamera
129+
m_Icon: {fileID: 0}
130+
m_NavMeshLayer: 0
131+
m_StaticEditorFlags: 0
132+
m_IsActive: 1
133+
--- !u!81 &1032722985
134+
AudioListener:
135+
m_ObjectHideFlags: 0
136+
m_CorrespondingSourceObject: {fileID: 0}
137+
m_PrefabInstance: {fileID: 0}
138+
m_PrefabAsset: {fileID: 0}
139+
m_GameObject: {fileID: 1032722984}
140+
m_Enabled: 1
141+
--- !u!20 &1032722986
142+
Camera:
143+
m_ObjectHideFlags: 0
144+
m_CorrespondingSourceObject: {fileID: 0}
145+
m_PrefabInstance: {fileID: 0}
146+
m_PrefabAsset: {fileID: 0}
147+
m_GameObject: {fileID: 1032722984}
148+
m_Enabled: 1
149+
serializedVersion: 2
150+
m_ClearFlags: 1
151+
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
152+
m_projectionMatrixMode: 1
153+
m_SensorSize: {x: 36, y: 24}
154+
m_LensShift: {x: 0, y: 0}
155+
m_GateFitMode: 2
156+
m_FocalLength: 50
157+
m_NormalizedViewPortRect:
158+
serializedVersion: 2
159+
x: 0
160+
y: 0
161+
width: 1
162+
height: 1
163+
near clip plane: 0.3
164+
far clip plane: 1000
165+
field of view: 60
166+
orthographic: 0
167+
orthographic size: 5
168+
m_Depth: -1
169+
m_CullingMask:
170+
serializedVersion: 2
171+
m_Bits: 4294967295
172+
m_RenderingPath: -1
173+
m_TargetTexture: {fileID: 0}
174+
m_TargetDisplay: 0
175+
m_TargetEye: 3
176+
m_HDR: 1
177+
m_AllowMSAA: 1
178+
m_AllowDynamicResolution: 0
179+
m_ForceIntoRT: 0
180+
m_OcclusionCulling: 1
181+
m_StereoConvergence: 10
182+
m_StereoSeparation: 0.022
183+
--- !u!4 &1032722987
184+
Transform:
185+
m_ObjectHideFlags: 0
186+
m_CorrespondingSourceObject: {fileID: 0}
187+
m_PrefabInstance: {fileID: 0}
188+
m_PrefabAsset: {fileID: 0}
189+
m_GameObject: {fileID: 1032722984}
190+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
191+
m_LocalPosition: {x: 0, y: 1, z: -10}
192+
m_LocalScale: {x: 1, y: 1, z: 1}
193+
m_Children: []
194+
m_Father: {fileID: 0}
195+
m_RootOrder: 0
196+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
197+
--- !u!1 &1341541627
198+
GameObject:
199+
m_ObjectHideFlags: 0
200+
m_CorrespondingSourceObject: {fileID: 0}
201+
m_PrefabInstance: {fileID: 0}
202+
m_PrefabAsset: {fileID: 0}
203+
serializedVersion: 6
204+
m_Component:
205+
- component: {fileID: 1341541629}
206+
- component: {fileID: 1341541628}
207+
m_Layer: 0
208+
m_Name: LocalStorage
209+
m_TagString: Untagged
210+
m_Icon: {fileID: 0}
211+
m_NavMeshLayer: 0
212+
m_StaticEditorFlags: 0
213+
m_IsActive: 1
214+
--- !u!114 &1341541628
215+
MonoBehaviour:
216+
m_ObjectHideFlags: 0
217+
m_CorrespondingSourceObject: {fileID: 0}
218+
m_PrefabInstance: {fileID: 0}
219+
m_PrefabAsset: {fileID: 0}
220+
m_GameObject: {fileID: 1341541627}
221+
m_Enabled: 1
222+
m_EditorHideFlags: 0
223+
m_Script: {fileID: 11500000, guid: eb7295d8fbaece0489b5fb85b3b0d6b0, type: 3}
224+
m_Name:
225+
m_EditorClassIdentifier:
226+
--- !u!4 &1341541629
227+
Transform:
228+
m_ObjectHideFlags: 0
229+
m_CorrespondingSourceObject: {fileID: 0}
230+
m_PrefabInstance: {fileID: 0}
231+
m_PrefabAsset: {fileID: 0}
232+
m_GameObject: {fileID: 1341541627}
233+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
234+
m_LocalPosition: {x: 0.037381306, y: -0.3642231, z: 0.49719962}
235+
m_LocalScale: {x: 1, y: 1, z: 1}
236+
m_Children: []
237+
m_Father: {fileID: 0}
238+
m_RootOrder: 2
239+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
240+
--- !u!1 &2127367621
241+
GameObject:
242+
m_ObjectHideFlags: 0
243+
m_CorrespondingSourceObject: {fileID: 0}
244+
m_PrefabInstance: {fileID: 0}
245+
m_PrefabAsset: {fileID: 0}
246+
serializedVersion: 6
247+
m_Component:
248+
- component: {fileID: 2127367623}
249+
- component: {fileID: 2127367622}
250+
m_Layer: 0
251+
m_Name: Directional Light
252+
m_TagString: Untagged
253+
m_Icon: {fileID: 0}
254+
m_NavMeshLayer: 0
255+
m_StaticEditorFlags: 0
256+
m_IsActive: 1
257+
--- !u!108 &2127367622
258+
Light:
259+
m_ObjectHideFlags: 0
260+
m_CorrespondingSourceObject: {fileID: 0}
261+
m_PrefabInstance: {fileID: 0}
262+
m_PrefabAsset: {fileID: 0}
263+
m_GameObject: {fileID: 2127367621}
264+
m_Enabled: 1
265+
serializedVersion: 8
266+
m_Type: 1
267+
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
268+
m_Intensity: 1
269+
m_Range: 10
270+
m_SpotAngle: 30
271+
m_CookieSize: 10
272+
m_Shadows:
273+
m_Type: 2
274+
m_Resolution: -1
275+
m_CustomResolution: -1
276+
m_Strength: 1
277+
m_Bias: 0.05
278+
m_NormalBias: 0.4
279+
m_NearPlane: 0.2
280+
m_Cookie: {fileID: 0}
281+
m_DrawHalo: 0
282+
m_Flare: {fileID: 0}
283+
m_RenderMode: 0
284+
m_CullingMask:
285+
serializedVersion: 2
286+
m_Bits: 4294967295
287+
m_Lightmapping: 4
288+
m_LightShadowCasterMode: 0
289+
m_AreaSize: {x: 1, y: 1}
290+
m_BounceIntensity: 1
291+
m_ColorTemperature: 6570
292+
m_UseColorTemperature: 0
293+
m_ShadowRadius: 0
294+
m_ShadowAngle: 0
295+
--- !u!4 &2127367623
296+
Transform:
297+
m_ObjectHideFlags: 0
298+
m_CorrespondingSourceObject: {fileID: 0}
299+
m_PrefabInstance: {fileID: 0}
300+
m_PrefabAsset: {fileID: 0}
301+
m_GameObject: {fileID: 2127367621}
302+
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
303+
m_LocalPosition: {x: 0, y: 3, z: 0}
304+
m_LocalScale: {x: 1, y: 1, z: 1}
305+
m_Children: []
306+
m_Father: {fileID: 0}
307+
m_RootOrder: 1
308+
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}

Assets/Scenes/scene_localstorage.unity.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/LocalStorage.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class LocalStorage : MonoBehaviour
6+
{
7+
// Start is called before the first frame update
8+
void Start()
9+
{
10+
PlayerPrefs.SetString("account", "123456");
11+
PlayerPrefs.SetString("password", "123456");
12+
PlayerPrefs.SetInt("stage", 2);
13+
PlayerPrefs.SetFloat("hp", 1200f);
14+
PlayerPrefs.Save();
15+
16+
if(PlayerPrefs.HasKey("account"))
17+
{
18+
Debug.Log("账户已存在");
19+
}
20+
else
21+
{
22+
Debug.Log(PlayerPrefs.GetString("account"));
23+
Debug.Log(PlayerPrefs.GetString("password"));
24+
}
25+
}
26+
27+
// Update is called once per frame
28+
void Update()
29+
{
30+
31+
}
32+
33+
private void OnApplicationQuit()
34+
{
35+
PlayerPrefs.DeleteAll();
36+
}
37+
}

Assets/Scripts/LocalStorage/LocalStorage.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# 本地存储
2+
3+
1. PlayerPrefs类:游戏开发中需要存储本地数据,借助这个能够实现本地存储;
4+
5+
2. PlayerPrefs主要方法:
6+
- SetInt/SetFloat,SetString: key --> value
7+
- GetInt/GetFloat/GetString: key --> value
8+
- DeleteKey/DeleteAll 删除一个key/所有数据
9+
- HasKey 判断一个key是否存在
10+
- Save保存数据

0 commit comments

Comments
 (0)