diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e742511..65ff2f73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Changed + +- Fixed an issue where Yarn projects that made use of the `visited` or `visit_count` functions could produce errors when re-importing the project. + ## [2.2.0] 2022-04-08 ### Added diff --git a/Editor/Importers/YarnProjectImporter.cs b/Editor/Importers/YarnProjectImporter.cs index b7b18f97..ba32240d 100644 --- a/Editor/Importers/YarnProjectImporter.cs +++ b/Editor/Importers/YarnProjectImporter.cs @@ -204,6 +204,9 @@ public override void OnImportAsset(AssetImportContext ctx) return; } + localDeclarations = localDeclarations + .Where(decl => decl.Name.StartsWith("$Yarn.Internal") == false); + // Store these so that we can continue displaying them after // this import step, in case there are compile errors later. // We'll replace this with a more complete list later if @@ -283,9 +286,15 @@ public override void OnImportAsset(AssetImportContext ctx) } // Store _all_ declarations - both the ones in this - // .yarnproject file, and the ones inside the .yarn files + // .yarnproject file, and the ones inside the .yarn files. + + // While we're here, filter out any declarations that begin with our + // Yarn internal prefix. These are synthesized variables that are + // generated as a result of the compilation, and are not declared by + // the user. serializedDeclarations = localDeclarations .Concat(compilationResult.Declarations) + .Where(decl => !decl.Name.StartsWith("$Yarn.Internal.")) .Where(decl => !(decl.Type is FunctionType)) .Select(decl => new SerializedDeclaration(decl)).ToList();