Quaternion To Matrix conversion failed

Getting error like this.
Don’t know why its coming.

Quaternion To Matrix conversion failed because input Quaternion is invalid {nan, nan, nan, nan} l=nan
UnityEngine.GUIUtility:RotateAroundPivot(Single, Vector2)
LineDrawer:DrawLine(Vector2, Vector2, Int32, Texture2D) (at Assets/Scripts/LineDrawer.cs:79)
LineDrawer:OnGUI() (at Assets/Scripts/LineDrawer.cs:64)

Next time include your code that produces the error. As you can see you managed to create an invalid Quaternion (all four values are “NaN” - Not a Number). Such errors happens when:

  • Any value involved is already a NaN value. So the cause might be somewhere earlier in code
  • you pass in values which will cause a NaN value.

Since you use RotateAroundPivot there are two possible sources:

  • the angle passed to RotateAroundPivot is either NaN or ± infinity
  • any component of the passed Vector3 is either NaN or ± infinity

Keep in mind that a number divided by zero results either in + or - infinity

My guess is that the angle passed is the problem.