Deleting Objects

👍

Reminder - Keep Daily Backups

When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.

What about deleting objects, like buildings?

Popular free-to-play games like Clash of Clans allow players to build structures but not delete them. We've decided to follow this model in the kit demo for v7.2, but leave the option for developers to work with building deletion in their own game.

Where can I enable deleting objects?

Although we recommend not using the delete object - for the early v6.0 release, the delete object procedural can be triggered by buttons in Scripts/Menus/Main/MenuMain.cs.
You'll see the functions connected to the hidden GUI menu delete buttons that appear on the building tap like the below excerpt:

// Excerpt of MenuMain.cs for Building delete buttons hidden in Unity
// 
//Building destroy
public void OnConfirmationBuilding()
{
  //the destroy building confirmation 
	Delay ();
	PauseMovement (true);
	DeleteBuildingYN.SetActive (true); 
	//StatsPadObj.SetActive (false);
}
public void OnCloseConfirmationBuilding() 
{ 
	PauseMovement (false);
	DeleteBuildingYN.SetActive (false); 
	Delay();
}

public void OnDestroyBuilding()
{
	((StructureCreator)buildingCreator).Cancel();
	DeleteBuildingYN.SetActive (false);
  //Delay();		//delay deferred to buildingCreator
}
public void OnCancelDestroyBuilding()
{
	((StructureCreator)buildingCreator).OK();
	DeleteBuildingYN.SetActive (false);
  //Delay(); 		//delay deferred to buildingCreator
}

🚧

Deleting functions

As of now the existing source code has implications we haven't fully tested to promise a bug-free experience for these delete buttons. In the future we'll go through this part again, but for now we've left the functions hidden but included for developers who want to see how it could be done.

Alternatives to deleting

Like clash of clans users usually do, instead of deleting which isn't possible in the game - users can relocate building objects around the map to places they don't use.

For developers, if you need to remove an object - for example if you build a wall segment you don't want, move it to the lower corner of the map and then you can manually delete it from the player save data file locating the object easily by looking in the save data file for the low grid coordinates (look for numbers like 2,3 or similar).

See the following example:

WoodFence,WoodEndSW,116,2,3

To understand more about what a save file looks like, please open the Online Server Sync > About Map Files section. Here's an excerpt from that section of the documentation. The breakdown of the save data for one object looks like this:

ItemDescription
WoodFenceObject Type
WoodEndSWObject
116Unique Object Index
2Row #2 (2,3 - these are in the grid origin - lower middle corner of the map.)
3Column #3 (2,3 - these are in the grid origin - lower middle corner of the map.)