Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CityGen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kent Holt
CityGen
Commits
40c68b68
Commit
40c68b68
authored
6 years ago
by
zohaib
Browse files
Options
Downloads
Patches
Plain Diff
Saving and loading functions are done
parent
d58a7af6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assets/Scripts/CityGen/CityGen.cs
+23
-7
23 additions, 7 deletions
Assets/Scripts/CityGen/CityGen.cs
with
23 additions
and
7 deletions
Assets/Scripts/CityGen/CityGen.cs
+
23
−
7
View file @
40c68b68
...
...
@@ -58,24 +58,40 @@ public class CityGen : MonoBehaviour {
}
void
save
(){
}
void
load
(){
}
}
public
City
city
;
private
string
jsonFilePath
=
"/CityData/data.json"
;
// Use this for initialization
void
Start
()
{
save
();
load
();
}
// Update is called once per frame
void
Update
()
{
}
// Save the data about city.
void
save
(
string
fileName
=
"data"
)
{
// Covert city ovject to json.
string
cityDataAsJson
=
JsonUtility
.
ToJson
(
this
.
city
);
//print(Application.persistentDataPath + this.jsonFilePath);
// Creates a directory in local disk.
System
.
IO
.
Directory
.
CreateDirectory
(
Application
.
persistentDataPath
+
"/CityData"
);
// Write all the data to a file.
System
.
IO
.
File
.
WriteAllText
(
Application
.
persistentDataPath
+
this
.
jsonFilePath
,
cityDataAsJson
);
}
// Load the data about city.
void
load
(){
string
cityDataAsJson
=
System
.
IO
.
File
.
ReadAllText
(
Application
.
persistentDataPath
+
this
.
jsonFilePath
);
city
=
JsonUtility
.
FromJson
<
City
>(
cityDataAsJson
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment