Forum rules - please read before posting.

Saving Disabled/Enabling game objects.


I'd like to save whether or not game objects are enabled or disabled. I've asked a similar question in the past but this is more specific

I know I can save it via the Remember Animator

Although I find this way a little convoluted, is there a way to do this with a script in AC that I've missed, or will I be able to do this with a custom script?

Here is an example

I'd like to disable this object, and record its enabled or disabled state

I imagine all it would need is a remember component on


that would record the enabled state of


I know this can be done with remember visibility and remember collider too. However there are some circumstances I need to disable objects which have custom scripts running on them.

Thanks for your help.


  • I'd advise caution when recording the enabled state of objects, but if you're going to do it - then storing the data on another object would certainly be the way to go.


    using UnityEngine;
    namespace AC
        public class RememberEnabledState : Remember
            public GameObject objectToRecord;
            public override string SaveData ()
                EnabledData data = new EnabledData();
                data.objectID = constantID;
                data.savePrevented = savePrevented;
                data.isEnabled = objectToRecord.activeSelf;
                return Serializer.SaveScriptData <EnabledData> (data);
            public override void LoadData (string stringData)
                EnabledData data = Serializer.LoadScriptData <EnabledData> (stringData);
                if (data == null) return;
                SavePrevented = data.savePrevented; if (savePrevented) return;
                objectToRecord.SetActive (data.isEnabled);
        public class EnabledData : RememberData
            public bool isEnabled;
            public EnabledData () { }

    And the Editor class, RememberEnabledState.cs (place this in an Editor subfolder):

    using UnityEngine;
    using UnityEditor;
    namespace AC
        [CustomEditor (typeof (RememberEnabledState), true)]
        public class RememberEnabledStateEditor : ConstantIDEditor
            public override void OnInspectorGUI()
                RememberEnabledState _target = (RememberEnabledState) target;
                _target.objectToRecord = (GameObject) EditorGUILayout.ObjectField ("Object to record:", _target.objectToRecord, typeof (GameObject), true);
                SharedGUI ();
  • Awesome thank you so much!
    Why do you caution not to do it out of curiosity? What issue would I be facing?

  • A disabled GameObject can cease to become "findable" in some cases, but in the end it really comes down to how extensively you use the object elsewhere. My suggestion would be to just try it and see.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.