Hello, I’m having trouble getting the Save and Load methods in script instances to run.
I have a ScriptInstance component attached to a node I call the “Game Mode Node”. This node is a child of the scene.
From the c++ side I want to call save and load on the “Game Mode Node” and have the Save and Load Methods in the ScriptObject to be called - however they are not.
C++:
File outFile(context_, “GreatGameTestSave.ggs”, FILE_WRITE);
Serializer& serializer = dynamic_cast<Serializer&>(outFile);pGameScriptNode->Save(serializer);
Creating the node and script instance:
pGameScriptNode = scene_->CreateChild();
pGameScriptInstance = pGameScriptNode->CreateComponent<ScriptInstance>();
pGameScriptInstance->SetScriptFile(context_->GetSubsystem<ResourceCache>()->GetResource<ScriptFile>(“Scripts/GreatGame/GreatGame.as”));
pGameScriptInstance->SetClassName(“GreatGame”);
GreatGame.as: (Attached as ScriptInstanceComponent to pGameScriptNode)
void Save(Serializer@ serializer){ Print("GreatGame Save.."); GameMode::Save(serializer); } void Load(Deserializer@ deserializer){ Print("GreatGame Load.."); GameMode::Load(deserializer); }