Skip to content

Commit ec1419a

Browse files
committed
Generate variable storage class after import completes
1 parent 6747dcc commit ec1419a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010

1111
### Changed
1212

13-
- `YarnProjectImporter` now updates asset addresses after the project import completes, rather than during the import.
13+
- `YarnProjectImporter` now updates asset addresses and generates the C# variable storage class after the project import completes, rather than during the import.
1414

1515
### Removed
1616

Editor/Importers/YarnProjectImporter.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,20 @@ public override void OnImportAsset(AssetImportContext ctx)
623623

624624
if (generateVariablesSourceFile)
625625
{
626-
627-
var fileName = variablesClassName + ".cs";
628-
629-
var generatedSourcePath = Path.Combine(Path.GetDirectoryName(ctx.assetPath), fileName);
630-
bool generated = GenerateVariableSource(generatedSourcePath, project, compilationResult);
631-
if (generated)
626+
// Generate the variable source; if it's different to what's
627+
// on disk, import it.
628+
var assetPath = ctx.assetPath;
629+
EditorApplication.delayCall += () =>
632630
{
633-
AssetDatabase.ImportAsset(generatedSourcePath);
634-
}
631+
var fileName = variablesClassName + ".cs";
632+
633+
var generatedSourcePath = Path.Combine(Path.GetDirectoryName(assetPath), fileName);
634+
bool generated = GenerateVariableSource(generatedSourcePath, project, compilationResult);
635+
if (generated)
636+
{
637+
AssetDatabase.ImportAsset(generatedSourcePath);
638+
}
639+
};
635640
}
636641
}
637642

0 commit comments

Comments
 (0)