Unity-Source-Tools icon indicating copy to clipboard operation
Unity-Source-Tools copied to clipboard

Error while importing GM_Construct

Open RedSpeeds opened this issue 4 years ago • 3 comments

Hey im trying to import gm_construct to test this tool using unity 2019 LTS. This is the error i get NullReferenceException: Object reference not set to an instance of an object uSrcTools.SourceBSPLoader.LoadEntity (System.Int32 index) (at Assets/Code/Read/SourceBSPLoader.cs:286) uSrcTools.SourceBSPLoader.Load (System.String mapName) (at Assets/Code/Read/SourceBSPLoader.cs:144) uSrcTools.Test.Load () (at Assets/Code/Test.cs:74) uSrcTools.MapLoader.OnInspectorGUI () (at Assets/Code/Test.cs:18) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <a259d3c004024353a2c217da97495055>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

RedSpeeds avatar Oct 04 '21 13:10 RedSpeeds

You might have forgotten to assign a variable, post the line of code which errored

Fronkln avatar Oct 06 '21 15:10 Fronkln

You might have forgotten to assign a variable, post the line of code which errored

https://github.com/lewa-j/Unity-Source-Tools/blob/master/Assets/Code/Read/SourceBSPLoader.cs#L286

RedSpeeds avatar Oct 06 '21 16:10 RedSpeeds

You might have forgotten to assign a variable, post the line of code which errored

https://github.com/lewa-j/Unity-Source-Tools/blob/master/Assets/Code/Read/SourceBSPLoader.cs#L286

Oh yeah, those lines of code don't have null checks so if it can't load the file it will error. You can fix this by changing their WrapMode and assigning them https://github.com/lewa-j/Unity-Source-Tools/blob/1c5dc0635cdc4c65775d4af2c4449be49639f46b/Assets/Code/Read/SourceBSPLoader.cs#L306-L311

only when they are not null.

Fronkln avatar Oct 07 '21 22:10 Fronkln