how recursive works in UdonSharp
UdonSharp stores local variables as class fields unless marked recursive, which adds stack push and pop overhead to prevent overwriting.
- UdonSharp typically compiles local variables as class fields, causing recursive function calls to overwrite values unless the recursive attribute is used
- The recursive attribute instructs the compiler to push and pop local variables on a stack, introducing slight performance overhead
- A recursive method may still function without the attribute if local variables are not written to prior to the self-call
- Calculating algorithms like Fibonacci without the recursive attribute produces incorrect results due to variable clobbering
- UdonSharp generates type-specific implementations for static generic functions, copying static functions directly into each calling class


