Save & Load Add-On
  • Welcome to Save & Load Add-On for FPS Engine!
  • BEFORE WE START
    • Early Considerations
    • Add-On Compatibility
    • List of Tutorials
  • GETTING STARTED
    • 01. Basic Set-Up
    • 02. Roadmap
  • CONTENT
    • 03. Content
      • 03.1 DataPersistence
        • DataPersistence_SO
        • DataPersistenceManager
        • FileDataHandler
        • GameData
        • GameDataManager
      • 03.2 Editor
      • 03.3 Item Registry
        • ItemRegistry
        • ItemRegistryEditor
        • ItemRegistryAssetProcessor
      • 03.4 Main Menu
        • SaveSlot
        • SaveSlotsMenu
      • 03.5 Objects Save Data
        • CustomSaveData
      • 03.6 Serialization
        • SerializableVector3
        • SafeSerializationBinder
      • 03.7 Triggers
        • SaveTrigger
        • LoadTrigger
        • ToggleAutoSave
      • 03.8 Type Registry
        • TypeRegistry
        • TypeToPrefabMappingDrawer
      • 03.9 UI
        • SaveLoadButton
    • 04. Shared Content for Add-Ons
      • ToastManager
      • WorkLight
  • HOW TO USE & GUIDES
    • Save & Load Games Programmatically
    • Saving Custom Data: Simple Method
    • Saving Custom Data: Advanced Method
    • Loading Custom Data
    • Saving Instantiated Objects
    • Save & Load System during Development
    • Working with Save & Load in Cowsins Manager
    • Uninstalling the Add-On: Fixing Errors
    • Type to Prefab Mappings in Game Data Manager
    • How to add Buttons to Save & Load a game
    • Non-Saveable Scenes
    • Loading Scenes & Load Player Data
  • FAQ
    • FAQ
  • SUPPORT
    • Support
Powered by GitBook
On this page
  1. HOW TO USE & GUIDES

Loading Custom Data

Whether you’ve saved your custom object data using the Simple or Advanced Method, your data will now be loaded and assigned automatically, with no extra effort required on your part!

Let’s consider a Door as an example. After interacting with the Door (interacted = true), you saved the interaction value (remember,interacted property from Interactables are automatically saved once interacted with). When you load your game, the interacted value will be set to true as expected. However, visually, the door will remain closed. This happens because we need to make a visual change to show that the door has been interacted with. To achieve this, we’ll use the LoadedState() method from Identifiable class.

LoadedState is called after loading

// Open or close the door based on whether it is interacted or not
// InteractedState is called after loading
public override void LoadedState()
{
    if (interacted)
    {
        doorPivot.position = initialPos + offsetPosition;
        doorPivot.localRotation = Quaternion.Euler(new Vector3(doorPivot.localRotation.x, openedDoorRotation * side, doorPivot.localRotation.z));
    }
    else
    {
        doorPivot.position = initialPos;
        doorPivot.rotation = closedRot;
    }
}
// LoadedState is called after loading
public override void LoadedState()
{
}

Here, after loading the interacted value, LoadedState() is called. To visually show that the door is indeed open, we update the door visuals.

This way, you can perform custom behaviours after loading the data of a custom object.

PreviousSaving Custom Data: Advanced MethodNextSaving Instantiated Objects

Last updated 1 month ago