docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SaveDuringPlay

    For all registered object types, record their state when exiting Play Mode, and restore that state to the objects in the scene. This is a very limited implementation which has not been rigorously tested with many objects types. It's quite possible that not everything will be saved.

    This class is expected to become obsolete when Unity implements this functionality in a more general way.

    To use this class, drop this script into your project, and add the [SaveDuringPlay] attribute to your class.

    Note: if you want some specific field in your class NOT to be saved during play, add a property attribute whose class name contains the string "NoSaveDuringPlay" and the field will not be saved.

    Inheritance
    object
    SaveDuringPlay
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Cinemachine.Editor
    Assembly: Unity.Cinemachine.Editor.dll
    Syntax
    [InitializeOnLoad]
    public class SaveDuringPlay

    Fields

    OnHotSave

    If you need to get notified before state is collected for hotsave, this is the place

    Declaration
    public static SaveDuringPlay.OnHotSaveDelegate OnHotSave
    Field Value
    Type Description
    SaveDuringPlay.OnHotSaveDelegate

    kEnabledKey

    Editor preferences key for SaveDuringPlay enabled

    Declaration
    public static string kEnabledKey
    Field Value
    Type Description
    string

    Properties

    Enabled

    Enabled status for SaveDuringPlay.
    This is a global setting, saved in Editor Prefs

    Declaration
    public static bool Enabled { get; set; }
    Property Value
    Type Description
    bool
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)