OnGUI using UnityEditor how to make FloatField work?

I want to give player options to have long float for mouse sensitivity and I do not want to restrict him

so my approach is giving him float and I’m kinda heaving problems

I was following this but I was heaving problems getting in .

I was following this but if I entered strange value I couldn’t repair it nor could I make float less big if needed like 15 or 15.1 and not 15.00

I was following this and tried to use that in answer but somehow I always got in to problem

than I followed this found my solution but just don’t understand it properly tho I have hard times understanding Java and even more I have hard time understanding new complicated stuff with too much useless info I like to see only what is necessary for something to work

my code

using UnityEngine;
using System.Collections;
using UnityEditor;

public class GuiFloat : MonoBehaviour {
	public float Length = 0;
	public float newLength = 0;
	
	void OnGUI(){
		newLength = EditorGUILayout.FloatField(Length);
	}
}

I’m getting error when I click the box

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.EditorGUI+RecycledTextEditor.IsEditingControl (Int32 id) (at C:/BuildAgent/work/812c4f5049264fad/Editor/MonoGenerated/Editor/EditorGUI.cs:152)
UnityEditor.EditorGUI.DoNumberField (UnityEditor.RecycledTextEditor editor, Rect position, Rect dragHotZone, Int32 id, Boolean isFloat, System.Single& floatVal, System.Int32& intVal, System.String formatString, UnityEngine.GUIStyle style, Boolean draggable, Single dragSensitivity) (at C:/BuildAgent/work/812c4f5049264fad/Editor/MonoGenerated/Editor/EditorGUI.cs:1164)
UnityEditor.EditorGUI.DoFloatField (UnityEditor.RecycledTextEditor editor, Rect position, Rect dragHotZone, Int32 id, Single value, System.String formatString, UnityEngine.GUIStyle style, Boolean draggable, Single dragSensitivity) (at C:/BuildAgent/work/812c4f5049264fad/Editor/MonoGenerated/Editor/EditorGUI.cs:1144)
UnityEditor.EditorGUI.DoFloatField (UnityEditor.RecycledTextEditor editor, Rect position, Rect dragHotZone, Int32 id, Single value, System.String formatString, UnityEngine.GUIStyle style, Boolean draggable) (at C:/BuildAgent/work/812c4f5049264fad/Editor/MonoGenerated/Editor/EditorGUI.cs:1139)
UnityEditor.EditorGUI.FloatField (Rect position, Single value, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/812c4f5049264fad/Editor/MonoGenerated/Editor/EditorGUI.cs:1013)
UnityEditor.EditorGUI.FloatField (Rect position, Single value) (at C:/BuildAgent/work/812c4f5049264fad/Editor/MonoGenerated/Editor/EditorGUI.cs:1009)
UnityEditor.EditorGUILayout.FloatField (Single value, UnityEngine.GUILayoutOption[] options) (at C:/BuildAgent/work/812c4f5049264fad/Editor/MonoGenerated/Editor/EditorGUI.cs:3433)
GuiFloat.OnGUI () (at Assets/GuiFloat.cs:10)

EditorGUILayout is only for custom inspector stuff. You don’t want to use that in OnGUI.