Search Issue Tracker
Won't Fix
Won't Fix in 2023.1.X
Votes
0
Found in
2022.3.2f1
2023.1.0f1
Issue ID
UUM-40618
Regression
No
"Unable to import newly created asset" errors are logged when creating a material from InitializeOnLoad
How to reproduce:
1. Open the attached “IN-44129” project
2. Observe the Console window
Expected result: No errors are displayed in the Console
Actual result: Errors are displayed in the Console
Reproducible with: 2022.3.2f1, 2023.1.0f1
Could not test with: 2021.3.27f1, 2023.2.0a20 - errors with custom packages
Testing environment: macOS 13.2.1 (M1 Max)
Errors:
Unable to import newly created asset : Assets/MyMaterial.mat
UnityEngine.StackTraceUtility:ExtractStackTrace ()
InitializeOnLoadCreateAsset:.cctor () (at Assets/InitializeOnLoadCreateAsset.cs:12)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[])
Note: Custom packages are used in the project
Comments (1)
-
y-iwanaga-01
Oct 19, 2023 09:38
A similar error message appears when using Deform 1.2.1 with Unity 2022.3.10f1.
>Unable to import newly created asset : Assets/Deform/EditorResources/DeformSettings.asset
[DeformEditorSettings.cs]
public static class DeformEditorSettings
{
[InitializeOnLoadMethod]
private static void EnsureSettingsAsset ()
{
if (settingsAsset == null)
settingsAsset = DeformEditorResources.LoadAssetOfType<DeformEditorSettingsAsset> (searchAssets: DeformEditorResources.SearchFilter.Assets);
if (settingsAsset == null)
{
settingsAsset = ScriptableObject.CreateInstance<DeformEditorSettingsAsset> ();
DeformEditorResources.CreateAsset (settingsAsset, "Deform/EditorResources/DeformSettings.asset"); //<-Here!
}
}
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
Resolution Note:
Asset operations such as asset loading should be avoided in InitializeOnLoad methods. InitializeOnLoad methods are called before asset importing is completed and therefore the asset loading can fail resulting in a null object. To do initialization after a domain reload which requires asset operations use the AssetPostprocessor.OnPostProcessAllAssets callback.
Docs: https://docs.unity3d.com/2023.2/Documentation/ScriptReference/InitializeOnLoadAttribute.html
Resolution Note (2023.1.X):
Asset operations such as asset loading should be avoided in InitializeOnLoad methods. InitializeOnLoad methods are called before asset importing is completed and therefore the asset loading can fail resulting in a null object. To do initialization after a domain reload which requires asset operations use the AssetPostprocessor.OnPostProcessAllAssets callback.
Docs: https://docs.unity3d.com/2023.2/Documentation/ScriptReference/InitializeOnLoadAttribute.html
Resolution Note (2023.1.X):
Asset operations such as asset loading should be avoided in InitializeOnLoad methods. InitializeOnLoad methods are called before asset importing is completed and therefore the asset loading can fail resulting in a null object. To do initialization after a domain reload which requires asset operations use the AssetPostprocessor.OnPostProcessAllAssets callback.
Docs: https://docs.unity3d.com/2023.2/Documentation/ScriptReference/InitializeOnLoadAttribute.html