I followed the documentation, but it didn’t work. I tested this in both Unity 6000.0.49f1 and 6000.0.53f1.
My Generator Code:
Log(context, $"Found {context.AdditionalFiles.Length} additional files.");
var i = 0;
foreach (var additionalFile in context.AdditionalFiles)
{
Log(context, $"[{++i}]{additionalFile.Path}");
var additionalFileContent = additionalFile.GetText(context.CancellationToken)?.ToString();
Log(context, additionalFileContent);
Log(context, "====================");
}
string requiredSuffix = $".additionalfile";
var stuFiles = context.AdditionalFiles.Where(f => f.Path.Contains(requiredSuffix)).ToList();
Log(context, $"Found {stuFiles.Count} additional files to process with suffix '{requiredSuffix}'.");
if (stuFiles.Count == 0)
{
Log(context,
"No additional files found. If this is unexpected, check your file naming convention, e.g., 'MyNode.[Analyzer Name].NodeGenerator.additionalfile'.");
Log(context, "NodeGenerator finished. No work to do.");
return;
}
Output Log:
error SSG_INFO: [MyGenerator] NodeGenerator execution started.
error SSG_INFO: [MyGenerator] Targeting assembly '[AssemblyName]' with root namespace '[AssemblyName]'.
error SSG_INFO: [MyGenerator] Found 1 additional files.
error SSG_INFO: [MyGenerator] [1]*\\Library/Bee/artifacts/1903b0aEDbg.dag/[AssemblyName].UnityAdditionalFile.txt
error SSG_INFO: [MyGenerator] [MyAssemblyRootPath]
error SSG_INFO: [MyGenerator] ====================
error SSG_INFO: [MyGenerator] Found 0 additional files to process with suffix '.additionalfile'.
error SSG_INFO: [MyGenerator] No additional files found. If this is unexpected, check your file naming convention, e.g., 'MyNode.[Analyzer Name].additionalfile'.
error SSG_INFO: [MyGenerator] NodeGenerator finished. No work to do.
Observations from the Log:
- My generator is not receiving a list of
.additionalfilefiles. It only receives one file. - The file path is:
Library/Bee/artifacts/191cb0aEDbg.dag/[AssemblyName].UnityAdditionalFile.txtThis reveals that Unity’s build system (Bee) is not passing.stu/.additionalfilefiles directly to the generator. Instead, it creates a temporary manifest file named[AssemblyName].UnityAdditionalFile.txt. - The content of the manifest file appears to be a list of paths (though in this case, it only contains one path—the root path, which is odd but hints at the underlying mechanism).
Questions:
- Has anyone else tried this? Did it work for you?
- Is my Unity version incorrect, or is this a bug?
- Are there alternative solutions to successfully implement
AdditionalFiles? I need support for multiple.additionalfilefiles.
Would appreciate any insights or workarounds!