INode* SpriteReader::CreateNodeWithJson(INodeEditor& editor, const rapidjson::Value& nodeTree, const StringRef& className /*= StringRef::Empty*/, NodeCreateFlags flags /*= NodeCreateFlags::None*/) { const rapidjson::Value& fileDataNode = nodeTree["FileData"]; StringRef path = fileDataNode.GetMember("Path", nullptr); Sprite* sprite = CreateSprite(path); SetPropsWithJson(sprite, nodeTree); return sprite; }
INode* ProjectNodeReader::CreateNodeWithJson(INodeEditor& editor, const rapidjson::Value& nodeTree, const StringRef& className /*= StringRef::Empty*/, NodeCreateFlags flags /*= NodeCreateFlags::None*/) { const rapidjson::Value& fileDataNode = nodeTree["FileData"]; StringRef filePath = fileDataNode.GetString("Path", nullptr); filePath = Path::GetFileName(filePath); RETURN_NULL_IF_FALSE(FileSystem::Instance().AssertExists(filePath)); INode* node = editor.Create("", filePath,IEventArg::Empty,flags); SetPropsWithJson(node, nodeTree, flags); return node; }
INode* LayerReader::CreateNodeWithJson(INodeEditor& editor, const rapidjson::Value& nodeTree, const StringRef& className /*= StringRef::Empty*/, NodeCreateFlags flags /*= NodeCreateFlags::None*/) { ILayer* node = nullptr; if (className.IsEmpty()) { node = LayerFactory::Instance().Create<NormalLayer>(IEventArg::Empty, flags); } else { node = LayerFactory::Instance().Create(className, FileIdRef::Empty, IEventArg::Empty, flags); } SetPropsWithJson(node, nodeTree,flags); #ifdef MEDUSA_SCRIPT if (ApplicationSettings::Instance().HasScriptBinding()) { node->TryAttachScriptObject(); } #endif return node; }