Search Unity

Implicit conversion operators crash Unity

Discussion in 'Editor & General Support' started by snacktime, Jun 22, 2019.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    So I have an external library with some structs that mirror Unity structs like Vector3, to play nice with some serialization we use on the server. It references UnityEngine.dll. The other day I converted some code from extension methods like ToVector3() to implicit conversion operators.

    Found out today that when used in the context of properties like Transform.position, it crashes Unity hard. No stack trace in the editor.

    This is on Unity 2019.1.71f.
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ok so it turns out I had an operator returning the wrong type. But that itself was covered by another operator so the end result was a stack overflow.