I have some trouble retrieving a ScriptObject’s Vector3 after reloading a saved scene.
Here is a simplified version of what I’m doing in lua:
[spoiler][code]
require “LuaScripts/Utilities/Sample”
function Start()
SampleStart()
scene_ = Scene()
SubscribeToEvent(“Update”, “HandleUpdate”)
local node = scene_:CreateChild(“MyNode”)
node:CreateScriptObject(“MyObject”)
end
MyObject = ScriptObject()
function MyObject:Start()
self.destination = Vector3(10, 0, 10)
end
function MyObject:Load(deserializer)
self.destination = deserializer:ReadVector3()
print(self.destination:ToString()) – Retrieval is OK
end
function MyObject:Save(serializer)
serializer:WriteVector3(self.destination)
end
function MyObject:Update(timeStep)
print(self.destination:ToString())
end
function HandleUpdate(eventType, eventData)
if input:GetKeyPress(KEY_F5) then scene_:SaveXML(fileSystem:GetProgramDir()…“Data/Scenes/TempExport.xml”) end
if input:GetKeyPress(KEY_F7) then scene_:LoadXML(fileSystem:GetProgramDir()…“Data/Scenes/TempExport.xml”) end
end
[/code][/spoiler]
After reloading the scene, deserialization is OK but self.destination is immediately overwritten to an almost Vector3.ZERO