{"__v":12,"_id":"548aef1bb77bb70b00ac8ccb","category":{"__v":14,"_id":"54890d71c178b40b00aa3086","project":"543b9b0065bf840e00b473d5","version":"543b9b0065bf840e00b473d8","pages":["548a63d41bd6c40b00f77728","548a6fbab77bb70b00ac8bf2","548adcb7b77bb70b00ac8c9d","548add501bd6c40b00f777d2","548ae445b77bb70b00ac8cad","548aef1bb77bb70b00ac8ccb","548af4b41bd6c40b00f777fc","548eb9d5e52d2b0b001b9a28","5508449ba42e812500b711f3","550a8eed42fff40d00ae60e3","550ce8fd6c0b4c0d00fd42fb","550ce9026c0b4c0d00fd42fd","550d840f11e8d00d00b80383","550e7e7f8387ac0d00ed9e1a"],"reference":false,"createdAt":"2014-12-11T03:20:17.529Z","from_sync":false,"order":5,"slug":"game-settings","title":"Game Settings"},"project":"543b9b0065bf840e00b473d5","user":"543b9aa865bf840e00b473d1","version":{"__v":11,"_id":"543b9b0065bf840e00b473d8","project":"543b9b0065bf840e00b473d5","createdAt":"2014-10-13T09:27:28.467Z","releaseDate":"2014-10-13T09:27:28.467Z","categories":["543b9b0065bf840e00b473d9","543b9ef065bf840e00b473e0","54890012f291f61400c02d36","54890902f291f61400c02d3e","54890c43f291f61400c02d44","54890d71c178b40b00aa3086","5508125c0c4d8c19008a5f83","55094050961f17170070abbd","550945111c38c50d006118ad","550a4c2e42fff40d00ae6049","55221c074801a40d00a77610"],"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"createdAt":"2014-12-12T13:35:23.691Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"settings":"","try":true,"auth":"never","params":[],"url":""},"order":3,"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"The load and save options seen in the screenshot below are for your development testing and can be disabled and auto-save enabled before distributing your game. (see below for instructions how)\",\n  \"title\": \"How to Enable Auto-Save:\"\n}\n[/block]\nThe kit comes with a few options in the Settings menu to control music and sounds, plus for desktop games, exiting if in fullscreen mode. The screenshots and references below are for the Pro and Complete Kit. The Starter Kit version includes Local Save and Local load options only.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://www.filepicker.io/api/file/Dg3g7d8pQF4DbjBxpKoB\",\n        \"advanced-kit.jpg\",\n        \"800\",\n        \"600\",\n        \"#6b8f1e\",\n        \"\"\n      ],\n      \"caption\": \"Screenshot of the Pro and Complete Kit Settings\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Setting\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"**Music**\",\n    \"1-0\": \"**Sounds**\",\n    \"2-0\": \"**Local Save**\",\n    \"3-0\": \"**Local Load**\",\n    \"4-0\": \"**Server Save**\",\n    \"5-0\": \"**Sever Load**\",\n    \"6-0\": \"**Exit Game**\",\n    \"6-1\": \"Closes the game. Useful for fullscreen desktop game deployment targets. Useless otherwise. Remove if deploying for mobile.\",\n    \"5-1\": \"**Development use only.** Uses Save/SaveLoadWWW.cs. If a Map ID is present, it loads the Map ID from the server. Only use after a Local and Server Save has been done or an error will occur.\",\n    \"4-1\": \"**Development use only.** Uses Save/SaveLoadWWW.cs. If the map data is present locally, it will send a copy of the local file to the server. Only use after a Local Save has been done or an error will occur since the server save uses a copy of the local save.\",\n    \"3-1\": \"**Development use only.** Uses Save/SaveLoadMap.cs. If the map data was successfully saved to the device locally before, this command will load the map. Useful when testing changes without having to restart the scene. You must have pressed Save before or an error will occur.\",\n    \"2-1\": \"**Development use only.** Uses Save/SaveLoadMap.cs. Saves the map data locally and overwrites any existing copy. Necessary to use before using any other Save or Load functions.\",\n    \"1-1\": \"Fades out the sound effects. Click again to fade in the sound effects.\",\n    \"0-1\": \"Fades out the music. Click again to fade in the music.\"\n  },\n  \"cols\": 2,\n  \"rows\": 7\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Saving and Loading\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Only load a saved game into a blank map\",\n  \"body\": \"If you load on an existing map, you'll have buildings overlapping. If you're distributing your game, see the code below auto-saving and auto-loading on application start. Otherwise when developing, only load a game into an empty map when you start the scene in Unity.\"\n}\n[/block]\nThe kit always starts with an empty map for development. Save and load your gameplay during testing using the Save and Load buttons. Open Settings menu in the game, and press Save. Building locations, resource values, and construction times will be saved.  Start the game, open settings, and press Load.\n[block:parameters]\n{\n  \"data\": {\n    \"2-0\": \"**SaveLoadBattle.cs**\",\n    \"0-0\": \"**SaveLoadMap.cs**\",\n    \"1-0\": \"**SaveLoadWWW.cs**\",\n    \"h-0\": \"Script\",\n    \"h-1\": \"Description\",\n    \"0-1\": \"Saves or loads the map data on the local device.\",\n    \"1-1\": \"Transfers to the server (included only with the Pro and Complete Kits)\",\n    \"2-1\": \"Downloads the battle results from the server (see Online Game Sync™ documentation)\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n**When ready to build your game, remove Save/Load buttons:**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://www.filepicker.io/api/file/gdm9fIyrT82XupjmkO8G\",\n        \"settings-save-load-buttoms.jpg\",\n        \"954\",\n        \"584\",\n        \"#c53720\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVTY6hGB41Lw%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVTY6hGB41Lw%26feature%3Dyoutu.be&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVTY6hGB41Lw%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\\\" width=\\\"854\\\" height=\\\"480\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://www.youtube.com/watch?v=VTY6hGB41Lw&feature=youtu.be\",\n  \"title\": \"Prepare to Submit #9\",\n  \"favicon\": \"https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico\",\n  \"image\": \"https://i.ytimg.com/vi/VTY6hGB41Lw/hqdefault.jpg\"\n}\n[/block]\n**In Hierarchy:**\n\n1. Go to UIAnchor/Anchor - Center and activate 02OptionsScreen \n2. Disable the 03SaveGame and 04LoadGame buttons\n3. Deactivate 02OptionsScreen\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://www.filepicker.io/api/file/BCkn5fk4S8ufJfkRsMIs\",\n        \"unity-starter-kit-disable-save-load-automatic-buttons.jpg\",\n        \"1000\",\n        \"562\",\n        \"#6cab4a\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n**Next, enable automatic saving and loading:**\n\nWhen developing, it's necessary to always start with a fresh game example. So there are two features commented out for development purposes. Uncomment them to enable automatic saving when the app closes and automatic loading when the app starts before publishing your game.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://www.filepicker.io/api/file/kWeeB3PSSgTfMO462DFA\",\n        \"automatic-load-save-unity-script-example-game.jpg\",\n        \"1000\",\n        \"687\",\n        \"#cc312e\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n**Save on Application Quit:**\n\nIn Project Browser:\n1. Open Assets/Scripts/SaveLoad.cs\n2. Insert this method before SaveGame (or anywhere in the class)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"void OnApplicationQuit() {\\nSaveGame();\\n}\\n\",\n      \"language\": \"csharp\",\n      \"name\": \"Excerpt from SaveLoad.cs\"\n    }\n  ]\n}\n[/block]\n**Load on Application Start:**\n\nIn Project:\n1. Open Assets/Scripts/SaveLoad.cs\n2. At the end of Start() call LoadGame();\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"void Start() {\\nLoadGame();\\n}\\n\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"settings","type":"basic","title":"Settings"}

Settings


[block:callout] { "type": "success", "body": "The load and save options seen in the screenshot below are for your development testing and can be disabled and auto-save enabled before distributing your game. (see below for instructions how)", "title": "How to Enable Auto-Save:" } [/block] The kit comes with a few options in the Settings menu to control music and sounds, plus for desktop games, exiting if in fullscreen mode. The screenshots and references below are for the Pro and Complete Kit. The Starter Kit version includes Local Save and Local load options only. [block:image] { "images": [ { "image": [ "https://www.filepicker.io/api/file/Dg3g7d8pQF4DbjBxpKoB", "advanced-kit.jpg", "800", "600", "#6b8f1e", "" ], "caption": "Screenshot of the Pro and Complete Kit Settings" } ] } [/block] [block:parameters] { "data": { "h-0": "Setting", "h-1": "Description", "0-0": "**Music**", "1-0": "**Sounds**", "2-0": "**Local Save**", "3-0": "**Local Load**", "4-0": "**Server Save**", "5-0": "**Sever Load**", "6-0": "**Exit Game**", "6-1": "Closes the game. Useful for fullscreen desktop game deployment targets. Useless otherwise. Remove if deploying for mobile.", "5-1": "**Development use only.** Uses Save/SaveLoadWWW.cs. If a Map ID is present, it loads the Map ID from the server. Only use after a Local and Server Save has been done or an error will occur.", "4-1": "**Development use only.** Uses Save/SaveLoadWWW.cs. If the map data is present locally, it will send a copy of the local file to the server. Only use after a Local Save has been done or an error will occur since the server save uses a copy of the local save.", "3-1": "**Development use only.** Uses Save/SaveLoadMap.cs. If the map data was successfully saved to the device locally before, this command will load the map. Useful when testing changes without having to restart the scene. You must have pressed Save before or an error will occur.", "2-1": "**Development use only.** Uses Save/SaveLoadMap.cs. Saves the map data locally and overwrites any existing copy. Necessary to use before using any other Save or Load functions.", "1-1": "Fades out the sound effects. Click again to fade in the sound effects.", "0-1": "Fades out the music. Click again to fade in the music." }, "cols": 2, "rows": 7 } [/block] [block:api-header] { "type": "basic", "title": "Saving and Loading" } [/block] [block:callout] { "type": "warning", "title": "Only load a saved game into a blank map", "body": "If you load on an existing map, you'll have buildings overlapping. If you're distributing your game, see the code below auto-saving and auto-loading on application start. Otherwise when developing, only load a game into an empty map when you start the scene in Unity." } [/block] The kit always starts with an empty map for development. Save and load your gameplay during testing using the Save and Load buttons. Open Settings menu in the game, and press Save. Building locations, resource values, and construction times will be saved. Start the game, open settings, and press Load. [block:parameters] { "data": { "2-0": "**SaveLoadBattle.cs**", "0-0": "**SaveLoadMap.cs**", "1-0": "**SaveLoadWWW.cs**", "h-0": "Script", "h-1": "Description", "0-1": "Saves or loads the map data on the local device.", "1-1": "Transfers to the server (included only with the Pro and Complete Kits)", "2-1": "Downloads the battle results from the server (see Online Game Sync™ documentation)" }, "cols": 2, "rows": 3 } [/block] **When ready to build your game, remove Save/Load buttons:** [block:image] { "images": [ { "image": [ "https://www.filepicker.io/api/file/gdm9fIyrT82XupjmkO8G", "settings-save-load-buttoms.jpg", "954", "584", "#c53720", "" ] } ] } [/block] [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVTY6hGB41Lw%3Ffeature%3Doembed&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVTY6hGB41Lw%26feature%3Dyoutu.be&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVTY6hGB41Lw%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\" width=\"854\" height=\"480\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://www.youtube.com/watch?v=VTY6hGB41Lw&feature=youtu.be", "title": "Prepare to Submit #9", "favicon": "https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico", "image": "https://i.ytimg.com/vi/VTY6hGB41Lw/hqdefault.jpg" } [/block] **In Hierarchy:** 1. Go to UIAnchor/Anchor - Center and activate 02OptionsScreen 2. Disable the 03SaveGame and 04LoadGame buttons 3. Deactivate 02OptionsScreen [block:image] { "images": [ { "image": [ "https://www.filepicker.io/api/file/BCkn5fk4S8ufJfkRsMIs", "unity-starter-kit-disable-save-load-automatic-buttons.jpg", "1000", "562", "#6cab4a", "" ] } ] } [/block] **Next, enable automatic saving and loading:** When developing, it's necessary to always start with a fresh game example. So there are two features commented out for development purposes. Uncomment them to enable automatic saving when the app closes and automatic loading when the app starts before publishing your game. [block:image] { "images": [ { "image": [ "https://www.filepicker.io/api/file/kWeeB3PSSgTfMO462DFA", "automatic-load-save-unity-script-example-game.jpg", "1000", "687", "#cc312e", "" ] } ] } [/block] **Save on Application Quit:** In Project Browser: 1. Open Assets/Scripts/SaveLoad.cs 2. Insert this method before SaveGame (or anywhere in the class) [block:code] { "codes": [ { "code": "void OnApplicationQuit() {\nSaveGame();\n}\n", "language": "csharp", "name": "Excerpt from SaveLoad.cs" } ] } [/block] **Load on Application Start:** In Project: 1. Open Assets/Scripts/SaveLoad.cs 2. At the end of Start() call LoadGame(); [block:code] { "codes": [ { "code": "void Start() {\nLoadGame();\n}\n", "language": "csharp" } ] } [/block]