HellBlazer
Member
Why can't I define a method with optional parameters inside a MonoBehaviour?
I get a warning that the names of the file it is in doesn't match, but my game doesn't crash, it just halts all ingame objects that use that class?
I have to move that method into its own class(nested also doesn't work) and away from any file where a class derived from MonoBehaviour is in.
I can then instantiate it inside a MonoBehaviour Object and use it just fine
Really weird but it works now.
Huh? You can use optional parameters in a MonoBehaviour just fine, I do it all the time. Have you renamed your behaviour class recently? The error about the file name not matching the class name means that, say, the TestClass class must be declared in a file named TestClass.cs. It's not directly related to method parameters at all. Did you maybe rename the class and not the file? Or maybe you just inadvertently changed the class name?