void ReferenceNode::Update(float32 timeElapsed)
{
	if(nodeToAdd)
	{
		AddNode(nodeToAdd);
		SafeRelease(nodeToAdd);
	}

	if(scene->IsReferenceNodeSuffixChanged())
	{
		RemoveAllChildren();
		String newFileName = FileSystem::Instance()->ReplaceExtension(customProperties->GetString("reference.path"), Format("_%s.sc2", scene->GetReferenceNodeSuffix().c_str()));
		SceneNode * node = scene->GetRootNode(newFileName);
		if(node)
		{
			nodeToAdd = node->Clone();
		}
		else
		{
			SceneNode * node = scene->GetRootNode(customProperties->GetString("reference.path"));
			nodeToAdd = node->Clone();
		}
	}
}
void ReferenceNode::Load(KeyedArchive * archive, SceneFileV2 * sceneFileV2)
{
	SceneNode::Load(archive, sceneFileV2);

	if(customProperties->IsKeyExists("reference.path"))
	{
		const String & relativePath = customProperties->GetString("reference.path");
		String absolutePath = sceneFileV2->RelativeToAbsolute(relativePath);
		customProperties->SetString("reference.path", absolutePath);
		SceneNode * node = scene->GetRootNode(absolutePath);
		if(node)
		{
			nodeToAdd = node->Clone();
		}
	}
}