@@ -32,18 +32,18 @@ FVector FPrefabricatorAssetUtils::FindPivot(const TArray<AActor*>& InActors)
32
32
Bounds += ActorBounds;
33
33
}
34
34
35
- switch (GetDefault< UPrefabricatorSettings>()->PivotPosition )
36
- {
37
- case EPrefabricatorPivotPosition::ExtremeLeft:
38
- Pivot = Bounds.GetCenter () - Bounds.GetExtent ();
39
- break ;
40
- case EPrefabricatorPivotPosition::ExtremeRight:
41
- Pivot = Bounds.GetCenter () + Bounds.GetExtent ();
42
- break ;
43
- case EPrefabricatorPivotPosition::Center:
44
- Pivot = Bounds.GetCenter ();
45
- break ;
46
- default :;
35
+ switch (GetDefault< UPrefabricatorSettings>()->PivotPosition )
36
+ {
37
+ case EPrefabricatorPivotPosition::ExtremeLeft:
38
+ Pivot = Bounds.GetCenter () - Bounds.GetExtent ();
39
+ break ;
40
+ case EPrefabricatorPivotPosition::ExtremeRight:
41
+ Pivot = Bounds.GetCenter () + Bounds.GetExtent ();
42
+ break ;
43
+ case EPrefabricatorPivotPosition::Center:
44
+ Pivot = Bounds.GetCenter ();
45
+ break ;
46
+ default :;
47
47
}
48
48
Pivot.Z = Bounds.Min .Z ;
49
49
}
@@ -95,7 +95,7 @@ UPrefabricatorAsset* UPrefabricatorAssetCollection::GetPrefabAsset(const FPrefab
95
95
96
96
FRandomStream Random;
97
97
Random.Initialize (InConfig.Seed );
98
-
98
+
99
99
TSoftObjectPtr<UPrefabricatorAsset> PrefabAssetPtr;
100
100
101
101
if (TotalWeight == 0 ) {
@@ -132,24 +132,44 @@ void UPrefabricatorProperty::SaveReferencedAssetValues()
132
132
{
133
133
AssetSoftReferenceMappings.Reset ();
134
134
135
- const FRegexPattern Pattern (*FPrefabricatorConstants::SoftReferenceSearchPattern);
135
+ const FString SoftReferenceSearchPattern = " ([A-Za-z0-9_]+)'(.*?)'" ;
136
+
137
+ const FRegexPattern Pattern (*SoftReferenceSearchPattern);
136
138
FRegexMatcher Matcher (Pattern, *ExportedValue);
137
139
138
140
while (Matcher.FindNext ()) {
141
+ FString FullPath = Matcher.GetCaptureGroup (0 );
142
+ FString ClassName = Matcher.GetCaptureGroup (1 );
143
+ FString ObjectPath = Matcher.GetCaptureGroup (2 );
144
+ if (ClassName == " PrefabricatorAssetUserData" ) {
145
+ continue ;
146
+ }
147
+ bool bUseQuotes = false ;
148
+ if (ObjectPath.Len () >= 2 && ObjectPath.StartsWith (" \" " ) && ObjectPath.EndsWith (" \" " )) {
149
+ ObjectPath = ObjectPath.Mid (1 , ObjectPath.Len () - 2 );
150
+ bUseQuotes = true ;
151
+ }
152
+
153
+ /*
139
154
int32 StartIdx = Matcher.GetMatchBeginning();
140
155
int32 EndIdx = Matcher.GetMatchEnding();
141
156
FString AssetPath = ExportedValue.Mid(StartIdx, EndIdx - StartIdx + 1);
142
157
if (AssetPath.StartsWith("PrefabricatorAssetUserData")) { // TODO: Get this name from the static class
143
158
continue;
144
159
}
145
- FSoftObjectPath SoftPath (AssetPath);
160
+ */
161
+
162
+ FSoftObjectPath SoftPath (ObjectPath);
146
163
147
164
FPrefabricatorPropertyAssetMapping Mapping;
148
165
Mapping.AssetReference = SoftPath;
149
- if (Mapping.AssetReference .IsValid ()) {
150
- FString ObjectPathString;
151
- FPackageName::ParseExportTextPath (AssetPath, &Mapping.AssetClassName , &ObjectPathString);
152
- Mapping.AssetObjectPath = *ObjectPathString;
166
+ // if (Mapping.AssetReference.IsValid())
167
+ {
168
+ // FString ObjectPathString;
169
+ // FPackageName::ParseExportTextPath(AssetPath, &Mapping.AssetClassName, &ObjectPathString);
170
+ Mapping.AssetClassName = ClassName;
171
+ Mapping.AssetObjectPath = *ObjectPath;
172
+ Mapping.bUseQuotes = bUseQuotes;
153
173
AssetSoftReferenceMappings.Add (Mapping);
154
174
UE_LOG (LogPrefabricatorAsset, Log, TEXT (" ######>>> Found Asset: [%s][%s] | %s" ), *Mapping.AssetClassName , *Mapping.AssetObjectPath .ToString (), *Mapping.AssetReference .GetAssetPathName ().ToString ());
155
175
}
@@ -176,8 +196,16 @@ void UPrefabricatorProperty::LoadReferencedAssetValues()
176
196
}
177
197
178
198
// The object path has changed. Update it and mark as modified
179
- FString ReplaceFrom = FString::Printf (TEXT (" %s\' %s\' " ), *Mapping.AssetClassName , *Mapping.AssetObjectPath .ToString ());
180
- FString ReplaceTo = FString::Printf (TEXT (" %s\' %s\' " ), *Mapping.AssetClassName , *ReferencedPath.ToString ());
199
+ FString ReplaceFrom, ReplaceTo;
200
+ if (Mapping.bUseQuotes ) {
201
+ ReplaceFrom = FString::Printf (TEXT (" %s\'\" %s\"\' " ), *Mapping.AssetClassName , *Mapping.AssetObjectPath .ToString ());
202
+ ReplaceTo = FString::Printf (TEXT (" %s\'\" %s\"\' " ), *Mapping.AssetClassName , *ReferencedPath.ToString ());
203
+ }
204
+ else {
205
+ ReplaceFrom = FString::Printf (TEXT (" %s\' %s\' " ), *Mapping.AssetClassName , *Mapping.AssetObjectPath .ToString ());
206
+ ReplaceTo = FString::Printf (TEXT (" %s\' %s\' " ), *Mapping.AssetClassName , *ReferencedPath.ToString ());
207
+ }
208
+
181
209
ExportedValue = ExportedValue.Replace (*ReplaceFrom, *ReplaceTo);
182
210
Mapping.AssetObjectPath = ReferencedPath;
183
211
0 commit comments