Purpose

Save agents and/or groups for later retrieval, allowing them to be loaded into the scene via custom menus.

How to Use

Instantiating Prefabs

  • On the left-side of the screen are prefabs that are either in the project or objects in the scene that can be instantiated. Clicking on any of the prefabs/objects on the left and then clicking on the plane in the game will spawn the objects. They default to a wander around behavior.

Saving Out an Agent to JSON

  • You can select units by clicking on them. When selected, the unit will have a green circular selector around them. When you have an agent selected, right-click to open the save menu. Enter the name of the save file and press enter. The right-side of the screen will update with the agent saved.

Saving Out a Group to JSON

  • You can select multiple units by click-hold and dragging the selector UI around the units you want selected. When right-clicking, the save menu will open for you to enter the name of the save file. When you press enter, the whole group will be saved into a file and the right-side of the screen will update with the group saved.

Loading a Saved Agent to the Scene

  • On the right-side of the screen are agents and groups that can be loaded into the scene at runtime. The first part of the list are agents that are saved to JSON. You can load them into the game the same way you load the prefabs/objects on the left-side of the screen. Loaded agents will spawn in the location where you originally clicked on the plane.

Loading a Saved Group to the Scene

  • The second part of the list on the right-side of the screen are groups. Those are merely buttons and clicking on them will spawn the objects in the groups into the scene. They will spawn in the same location as when they were saved.

Scene Location & Name

Assets/Ride/Examples/UnitData/UnitDataExample.unity

Save File Locations

  • Assets/unitData/groups/
  • Assets/unitData/units/

Note

Currently, any save files no longer desired must be manually deleted by the user from these folders to remove them from the JSON Units menu at run-time.

Setup Requirements 

Utilize the save/load ability and selector API with an assist list and UI options for your scene by adding the UnitDataExample script, SelectorUI prefab, GOList prefab, vehicle prefabs, and a custom Canvas object with buttons. 

UnitDataExample script

First, add this script to an object in your scene to enable the spawning of units for saving/loading.

SelectorUI prefab

Next, import the SelectorUI prefab into your scene to enable rectangular selection and highlight of units by way of the RectSelectionDisplay script.

This prefab also contains the necessary EventSystem and Canvas child prefabs. 

GOList and vehicle prefabs

Next, import the GOList prefab into your scene. This list determines which assets are available in the scene. By default the list is populated with 0 Scene Game Objects and 20 Unit Prefabs.

Remove the VehHmvM111402Prefab from the Unit Prefabs list by changing the Unit Prefabs field Size to 19. Change the Size value of Scene Game Objects to 2. 

Now, import Abrams and VehHmvM111402Prefab prefabs into the scene. Hide (uncheck) both instances by default in the scene.

Add both objects to Scene Game Objects under the GOList.

Custom Canvas object and buttons

Last, instance a new Unity Canvas object in the scene. Add a ToggleGroup component to the object, from the following loaction: Pakages/com.unity.ugui/Runtime/UI/Core/ToggleGroup.cs

Place three Panel objects as children, renaming them as follows: GO_ListSpawnList, UnitDataSavePanel and JSONSpawnList. Refer to the example scene assets to create/copy the various on-screen buttons and menus within these panels.

Note

A future update may include the ToggleGroup functionality within the RIDE Canvas prefab, as well as a new Canvas prefab with GO_ListSpawnList, UnitDataSavePanel and JSONSpawnList ready for drag-and-drop scene placement.

Scroll Up