51 TArray<TSharedPtr<FJsonValue>> ResultPropJsonArray;
57 FFileHelper::LoadFileToString(JsonString, *DefaultPropFilePath);
59 TSharedPtr<FJsonObject> JsonObject = MakeShareable(
new FJsonObject());
60 TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(JsonString);
63 TMap<FString, int> PropIndexes;
64 if (FJsonSerializer::Deserialize(JsonReader, JsonObject) && JsonObject.IsValid())
67 for (int32 i = 0; i < ResultPropJsonArray.Num(); ++i)
69 TSharedPtr<FJsonObject> PropJsonObject = ResultPropJsonArray[i]->AsObject();
73 PropIndexes.Add(Name, i);
78 for (
auto &PropParameter : PropParametersArray)
80 TSharedPtr<FJsonObject> PropJsonObject;
83 int *PropIndex = PropIndexes.Find(PropParameter.Name);
86 PropJsonObject = ResultPropJsonArray[*PropIndex]->AsObject();
90 PropJsonObject = MakeShareable(
new FJsonObject);
99 TSharedRef<FJsonValue> PropJsonValue = MakeShareable(
new FJsonValueObject(PropJsonObject));
102 ResultPropJsonArray[*PropIndex] = PropJsonValue;
106 ResultPropJsonArray.Add(PropJsonValue);
108 PropIndexes.Add(PropParameter.Name, ResultPropJsonArray.Num() - 1);
116 FString OutputString;
117 TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&OutputString);
118 FJsonSerializer::Serialize(JsonObject.ToSharedRef(), Writer);
121 FFileHelper::SaveStringToFile(OutputString, *DefaultPropFilePath);
131 TArray<FString> PropFileNames;
132 IFileManager::Get().FindFilesRecursive(PropFileNames,
140 PropFileNames.Sort();
141 FString DefaultFileName;
142 for (int32 i = 0; i < PropFileNames.Num() && DefaultFileName.IsEmpty(); ++i)
146 DefaultFileName = PropFileNames[i];
147 PropFileNames.RemoveAt(i);
150 if (!DefaultFileName.IsEmpty())
152 PropFileNames.Insert(DefaultFileName, 0);
157 TMap<FString, int> PropIndexes;
159 for (int32 i = 0; i < PropFileNames.Num(); ++i)
161 FString FileJsonContent;
162 if (FFileHelper::LoadFileToString(FileJsonContent, *PropFileNames[i]))
164 TSharedPtr<FJsonObject> JsonParsed;
165 TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(FileJsonContent);
166 if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
170 for (
auto &PropJsonValue : PropJsonArray)
173 TSharedPtr<FJsonObject> PropJsonObject = PropJsonValue->AsObject();
180 UStaticMesh *PropMesh = LoadObject<UStaticMesh>(
nullptr, *PropMeshPath);
185 if (PropIndexes.Contains(PropName))
187 PropParametersArray[PropIndexes[PropName]] = Params;
191 PropParametersArray.Add(Params);
192 PropIndexes.Add(Params.Name, PropParametersArray.Num() - 1);