Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

NullReferenceException when importing/compiling code + Editor Freeze #130

Open
tfJonathan opened this issue Sep 30, 2020 · 3 comments
Open

Comments

@tfJonathan
Copy link

Hi,
When importing the latest version of the bHaptics unity plugin (v1.5.1) into the editor it throws a NullReferenceException.
This will happen again when recompiling code. I've also had frequent freezes of the unity editor (needed to be shutdown via the taskmanager) which might be related since they started right after importing the plugin.

In the error message the script 'HapticClipManager' seems to be causing a problem.
Upon inspecting this script it seems to be a scriptable object with execute in edit mode attribute which seems a bit strange since it's a class with static helper methods and holds no data of its own.
Sadly making it just a static class did not fix the problem.

I've tried it in unity 2018.4.24f1 and 2019.4.8f1 both versions seem to have the issue.

image

NullReferenceException: Object reference not set to an instance of an object UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.FindClassAndNamespace (System.String className, System.String source, System.Boolean acceptStruct) (at <d7545a46516941d4b2f2dec578cd41ee>:0) UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.FindNamespace (System.String sourceCode, System.String className, System.Boolean acceptStruct, System.String[] defines) (at <d7545a46516941d4b2f2dec578cd41ee>:0) Rethrow as IllegalNamespaceParsing: Searching for classname: 'HapticClipManager' caused error in CSharpNameParser UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.FindNamespace (System.String sourceCode, System.String className, System.Boolean acceptStruct, System.String[] defines) (at <d7545a46516941d4b2f2dec578cd41ee>:0) UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.GetClassAndNamespace (System.String sourceCode, System.String className, System.String& outClassName, System.String& outNamespace, System.String[] defines) (at <d7545a46516941d4b2f2dec578cd41ee>:0) UnityEditor.Scripting.Compilers.CSharpLanguage.GetClassAndNamespace (System.String filePath, System.String definedSymbols, System.String& outClassName, System.String& outNamespace) (at <d7545a46516941d4b2f2dec578cd41ee>:0) UnityEditor.Scripting.ScriptCompilers.GetClassAndNamespace (System.String file, System.String definedSymbols, System.String& outClassName, System.String& outNamespace) (at <d7545a46516941d4b2f2dec578cd41ee>:0)

@tfJonathan
Copy link
Author

Update: the frequent freezes seem to come from TactFileWatcher.cs.
I'm guessing something goes wrong with the FileSystemWatcher when entering/exiting playmode or recompiling scripts since it triggers [InitializeOnLoadMethod] which recreates the watchers.

After commenting out all code in TactFileWatcher.cs and HapticClipManager.cs the freezes have stopped.

@westside
Copy link
Contributor

westside commented Oct 2, 2020

Really sorry for your inconvenience.
Those scripts are related to converting from tact files to unity asset files.
It scans all projects folder to find tact files to convert it to asset files and there might be some exceptional case.

We'll check that out and let you know soon. (Anyway it doesn't make any problem on your build file.)

If you have any further information, please let me know.

@SanghunK
Copy link
Contributor

SanghunK commented Oct 8, 2020

If you change the code of HapticClipManager.cs - line 203, NullReferenceException error will be fixed.
File.WriteAllText(path + @"\" + allInstance.name + ".tact", allInstance.JsonValue);
-> File.WriteAllText(path + "\\" + allInstance.name + ".tact", allInstance.JsonValue);

And i'm also trying to fix the frequent freezes issue. sorry for your inconvenience..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants