Forum rules - please read before posting.

Saving custom scene data

edited January 2018 in Technical Q&A
Hey Chris,

First of all happy new year! Hope you had great time during new years and Christmas.

So I was trying to save custom scene data, and I've created my own script for that using your tutorial. But it doesn't seem to be working for some reason. It's attached to a gameobject that has Image component on it. The way that games are saved in my game is through checkpoints, so it just autosaves over the last autosave using this line of code:

SaveSystem.SaveAutoSave();

and I load with a button that loads last saved game through action list. Here is the script:
Script


What am I doing wrong? Thanks in advance.

Comments

  • Looks fine.  Are both Debug.Log statements appearing in the Console, and what is the script attached to?  Is it spawned at runtime or present in the scene file?
  • None of the Debug.Log statements are appearing, forgot to mention that. The script is attached to few UI elements that contain Image component on it and they are present in the scene file. I also have a second script just like that but it is used for Text components instead of Image. All of the Image and Text components that have these scripts attached are disabled at the beginning (just the components not the gameobjects), and they are enabled and saved in the same function (enabling is done 1st of course).


  • It works for me - at least, the logs appear.  Which versions of AC/Unity are you using (please mention these as a rule when posting), and on what platform?

    Also, how does it behave when handled via the Save/Load menus?  You can temporarily assign the Default_MenuManager asset in the Menu Manager to bring them back if your own game doesn't use them.
  • AC version: 1.60.4
    Unity version: 2017.3.0f3
    Platform: PC, Mac & Linux Standalone.

    And I'm working on the PC all the time. I've tried with the default saving/loading menus but it doesn't work either. I should mention that remember hotspot, animation, transform and scripts like that work in both autosave and default saving/loading menus.
  • Do you have multiple scenes open at a time, or just the one?  That it's picking up the standard scripts and not yours is confusing, since I can see no issue with it.

    The next step will be to insert some Debug.Log statements into AC's code to try to see why it's not picking it up.

    The various Remember components are gathered in the PopulateScriptData method inside the LevelStorage script - around line 445.  Just inside the foreach loop, paste in the following:

    Debug.Log ("Processing: " + _script.name + " on object: " + _script.gameObject.name + ", subScene: " + subScene);

    What does that output when you save in the scene in question?
  • edited January 2018
    Only one scene is open at a time.

    Output:

    Processing: PersistentEngine on object: PersistentEngine, subScene: 
    UnityEngine.Debug:Log(Object)

    and for 3 more objects in the scene that have Remember scripts on them, but the objects that have my remember scripts on it are not appearing.
    But I managed to find out what was causing the problem. The canvas that contained my images and texts that I was trying to save had ConstantID script on itself, because I was using it for a menu, and once you set your canvas as Linked Canvas in Menu properties it gets that script on itself. So after I assigned some other canvas to that menu and deleted the ConstantID script from the canvas that has my custom remember scripts, saving works for them as well. Thanks for the help Chris I'm glad we got to the end of it. By the way is this how it's supposed to work? If a parent object has ConstantID script on itself it's children objects can't use remember scripts? Hope it isn't because I want some of those buttons to be in the AC menu and to have remember scripts on as well.
  • No, that should be fine.  It could be due to the necessity of inactive Unity UI-based Menus to have their GameObjects disabled completely to prevent them from being picked up by the Event System (this is a Unity bug so far as I can tell).  Regardless, glad it's working for you now.
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.