Error in Unity 5.4.0b24: LoadAssetAtPath is not allowed to be called from a ScriptableObject constructor
I'm getting an error in Unity 5.4.0b24
LoadAssetAtPath is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'SF_Editor'. See "Script Serialization" page in the Unity Manual for further details. UnityEditor.AssetDatabase:LoadAssetAtPath(String, Type) ShaderForge.SF_Resources:LoadInterfaceIcon(String) ShaderForge.SF_GUI:get_Icon() ShaderForge.SF_Editor:.ctor() UnityEditor.EditorWindow:GetWindow(Type) ShaderForge.SF_Editor:Init(Shader) ShaderForgeMaterialInspector:OnInspectorGUI() (at Assets/3rdParty/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeMaterialInspector.cs:85) UnityEditor.DockArea:OnGUI()
and also
UnityException: LoadAssetAtPath is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'SF_Editor'.
See "Script Serialization" page in the Unity Manual for further details.
ShaderForge.SF_Resources.LoadInterfaceIcon (System.String name)
ShaderForge.SF_GUI.get_Icon ()
ShaderForge.SF_Editor..ctor ()
UnityEditor.EditorWindow:GetWindow(Type)
ShaderForge.SF_Editor:Init(Shader)
ShaderForgeMaterialInspector:OnInspectorGUI() (at Assets/3rdParty/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeMaterialInspector.cs:85)
UnityEditor.DockArea:OnGUI()
I know it's still a beta version, but I figure it probably will show up in the upcoming release.
Odpowiedź
Longtime fan. Love Shader Forge. When do you think 1.27 will be available Joachim? I am on a time sensitive project that is forced to use 5.4.0b23 or higher. I can pop back and make stuff in 5.3 and then copy it to 5.4 but the workflow is not great moving through projects like that.
so i pulled down 1.27, and unfortunately there still seems to be a problem. Shader Forge window pops up when launched and instantly closes. it tried it in both a clean and working project. Any thoughts on this?
Are you sure you're running 1.27? Does it always happen, both when opening through Window -> Shader Forge, or only when opening it through the "open in shader forge" button on materials/shaders?
i'm sure its on 1.27, files are timestamped to today/yesterday. SF will not open from either method available. i get 20 some warning all about formatting when i import SF into my project, all similar to this... "There are inconsistent line endings in the 'Assets/ShaderForge/Editor/InternalResources/GPU Rendering/SFN_Parallax/SFN_Parallax_UV.shader' script. Some are Mac OS X (UNIX) and some are Windows.This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands."
Seeing a version of this same error using UCLA Mesh Creator in App store with Unity 5.4. It throws a few others, but this first error seems to kick off the others. The initialization code appears consistent with docs for EditorWindow.GetWindow.
Load is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'MeshCreatorWizard'. See "Script Serialization" page in the Unity Manual for further details. UnityEngine.Resources:Load(String) MeshCreatorWizard:.ctor() UnityEditor.EditorWindow:GetWindow(Type, Boolean, String) MeshCreatorWizard:Init() (at Assets/UCLAGameLab/Editor/MeshCreatorWizard.cs:70)
There should be enough information there to replicate and either provide a fix or revise docs.
Customer support service by UserEcho
This has been fixed in 1.27