Save agents and/or groups for later retrieval, allowing them to be loaded into the scene via custom menus.
Saving Out an Agent to JSON
Saving Out a Group to JSON
Loading a Saved Agent to the Scene
Loading a Saved Group to the Scene
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.
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.
First, add this script to an object in your scene to enable the spawning of units for saving/loading.
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.
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.
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.
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.