Skip to content

Commit c0ca4e1

Browse files
committed
Fix background export
1 parent e3c753b commit c0ca4e1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ExportToGMS1Project.csx

+7-6
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ void ExportBackground(UndertaleBackground background)
162162
new XComment(gmxDeclaration),
163163
new XElement("background",
164164
new XElement("istileset", "-1"),
165-
new XElement("tilewidth", background.Texture.BoundingWidth.ToString()),
166-
new XElement("tileheight", background.Texture.BoundingHeight.ToString()),
165+
new XElement("tilewidth", background.Texture == null ? "0" : background.Texture.BoundingWidth.ToString()),
166+
new XElement("tileheight", background.Texture == null ? "0" : background.Texture.BoundingHeight.ToString()),
167167
new XElement("tilexoff", "0"),
168168
new XElement("tileyoff", "0"),
169169
new XElement("tilehsep", "0"),
@@ -174,16 +174,17 @@ void ExportBackground(UndertaleBackground background)
174174
new XElement("TextureGroup0", "0")
175175
),
176176
new XElement("For3D", "0"),
177-
new XElement("width", background.Texture.BoundingWidth.ToString()),
178-
new XElement("height", background.Texture.BoundingHeight.ToString()),
177+
new XElement("width", background.Texture == null ? "0" : background.Texture.BoundingWidth.ToString()),
178+
new XElement("height",background.Texture == null ? "0" : background.Texture.BoundingHeight.ToString()),
179179
new XElement("data", "images\\" + background.Name.Content + ".png")
180180
)
181181
);
182182

183183
File.WriteAllText(projFolder + "/background/" + background.Name.Content + ".background.gmx", gmx.ToString());
184184

185185
// Save background images
186-
worker.ExportAsPNG(background.Texture, projFolder + "/background/images/" + background.Name.Content + ".png");
186+
if (background.Texture != null)
187+
worker.ExportAsPNG(background.Texture, projFolder + "/background/images/" + background.Name.Content + ".png");
187188
}
188189
// --------------- Export Object ---------------
189190
async Task ExportGameObjects()
@@ -688,4 +689,4 @@ void WriteIndexes<T>(XElement rootNode, string elementName, string attributeName
688689
resourcesNode.Add(resourceNode);
689690
}
690691
rootNode.Add(resourcesNode);
691-
}
692+
}

0 commit comments

Comments
 (0)