I have managed to make some small changes to get obfuscar working a
little better with Unity... It's not 100% there yet but almost
For one I changed line 810 of Obfuscar.cs to:if (info.ShouldSkip(methodKey) || method.ReturnType.Name=="IEnumerator")This should prevent your Coroutines called using StartCoroutine(string) from being missed.
Another change on line 436 of Obfuscar.cs
if (type.DeclaringType != null || type.Namespace=="")
Will prevent MonoBehaviours from being put in a namespace. But of course there are some more issues...
One is that you will get errors (readable in the output_log file with a Stand-Alone build) when you obfuscate the MonoBehaviour derived class names. For example:
The class defined in script file named 'Sun' does not match the file name!
(Filename: C:/BuildAgent/work/f724c1acfee760b6/Runtime/Mono/MonoBehaviour.cpp Line: 1650)Because the Sun class has had its name changed. I haven't yet found where this name is still residing after you obfuscate. Possibly in the .exe itself, which you cant decompile in Reflector as far as I know. It may be possible to search for and replace all of the references wherever they reside if they exist as strings.
To get around this for now you can just skip obfuscating the MonoBehaviour derived class-names (but still obfuscate their innards) by using these directives in the XML config:
<SkipType name="^[^\.]*$" skipMethods="false" skipFields="false" skipProperties="false" skipEvents="false"/>So now my game starts but I still have a major issue. It seems Coroutines are still not working... From output_log.txt:
Coroutine 'CoroutineMethodName' couldn't be started!Which is strange, considering I can look in the obfuscated class in Reflector and see that this Coroutine is indeed there and it looks the same as in the non-obfuscated .dll