This error generally means that Unity is repeatedly detecting changes to the source asset and triggering your importer in an endless loop. Even if your code isn’t explicitly writing anything, there are a few common causes when dealing with third‑party libraries or file formats like NetCDF:
What Happens:
Some libraries (or their native dependencies) may access the file in a way that changes its metadata or even its internal timestamps. For example, when you call DataSet.Open(path), the NetCDF library might create temporary lock files or update file attributes. If these changes occur in the same folder (i.e. inside your Assets folder), Unity’s asset database sees them as a modification, which causes the importer to run again.
How to Check:
- Verify if the NetCDF library writes any temporary files or modifies file timestamps.
- Test by reading the file without processing it (or open a copy of the file from a non‑Assets folder) to see if the error persists.
What Happens:
Even small modifications made to the asset on disk or in its meta data during the import process can be picked up by Unity as a change. For example, if your importer (or the library it calls) creates or updates a file in the same directory, Unity will re-import it, starting the cycle again.
How to Check:
- Ensure that your code and any libraries you use open files in read‑only mode.
- Check that you’re not inadvertently writing to the same file or modifying asset meta data.
What Happens:
If your importer creates a dependency or references back to the source asset or writes additional asset files in the same path, Unity may treat those changes as modifications to the original asset, causing another import.
How to Check:
- Review any calls (directly or indirectly) that might trigger
AssetDatabase.Refresh() or similar functions.
- Make sure your importer isn’t referencing the asset in a way that would trigger Unity to mark it as “changed.”
Steps to Diagnose:
-
Isolate the Operation:
Temporarily remove or comment out the DataSet.Open(path) call (or replace it with a simple read) and see if the error stops. This helps confirm whether the NetCDF library call is the culprit.
-
Check for Temporary Files:
Look in your project’s Assets folder for any additional files that might be created during the import process (e.g., lock files or cache files). If found, consider configuring the library to use a system temporary folder outside of the project.
-
Ensure Read‑Only Access:
Confirm that your method of opening the file does not modify it. If the library has options for opening files in read‑only mode, enable those.
-
Separate Processing:
As a workaround, consider copying the file to a temporary location (outside the Assets folder), processing it there, and then using the data to create your asset. This way, any temporary modifications won’t affect the source asset that Unity is tracking.
Example Adjustment:
If the library offers configuration options (check its documentation or API), you might set it to open in read‑only mode. For example (pseudocode):
var settings = new NetCDFReaderSettings { ReadOnly = true, TempPath = System.IO.Path.GetTempPath() };
using var ds = DataSet.Open(path, settings);
(Note: Replace with the actual API calls provided by the NetCDF library if available.)
The infinite import loop is most likely caused by the NetCDF library (or its dependencies) making changes to the asset’s file metadata or leaving behind temporary files in your Assets folder. Unity sees these changes and triggers the importer over and over. Check the library’s behavior regarding file access and temporary file creation, and consider configuring it to work entirely in read‑only mode or using an external temporary folder. By isolating these side effects, you can break the cycle and stop the infinite import loop.
If you need further assistance, please provide additional details about the NetCDF library’s configuration or any observed file modifications.