Obfuscator
This extension applies obfuscation to your assemblies.
Subscribed hooks
Assembly creation
This extension modifies assembly stream in assembly creation hook.
Options
Naming Strategy
Strategy | Description |
---|---|
Non Printable | Use non-printable control characters for names |
Guid | Use GUID for names |
Filtering Strategy
Strategy | Description |
---|---|
Automatic | Use default strategy |
Custom | Use a config file for advanced control |
Automatic
The automatic strategy for obfuscation processes the following types and members:
- Non-public types
- Except those derived from
UnityEngine.Object
. - Except those marked with the
System.Reflection.ObfuscationAttribute(Exclude = true)
attribute.
- Except those derived from
- Members of non-public types, or private members of public types
- Except those marked with
UnityEngine.SerializeField
,UnityEngine.PropertyAttribute
, orSystem.Reflection.ObfuscationAttribute(Exclude = true)
attributes. - Except those with
abstract
,override
orvirtual
modifiers - Except those with Unity-specific method names (e.g.
Awake
,Update
) within types derived fromUnityEngine.Object
- Except those public fields within types marked with the
System.Serializable
attribute.
- Except those marked with
Overloads are treated as a single method (they'll have the same name after obfuscation).
Custom
To generate a custom config template file, follow these steps:
- Switch to "Automatic".
- Click the refresh icon button in the "Preview Config" section.
- If processing succeeds, click the save icon button to export the config.
You can make changes to the config file and switch back to "Custom" to use the modified config file.
An exmaple config file:
<obfuscation>
<type name="MyNamespace.MyHelperClass" exclude="true">
<member name="MyStaticMethod" />
</type>
<type name="MyNamespace.MyInternalClass">
<member name="_myPrivateField" />
</type>
<type name="MyNamespace.MyPublicClass" exclude="true" />
</obfuscation>
In a config file, only listed types and members will be obfuscated. If a type or member has an attribute exclude
set to true, the type or member itself will be excluded from obfuscation, but not their members. You need to explicitly set the attribute for each member you want to exclude, or simply remove them from the list.
You can also use System.Reflection.ObfuscationAttribute
with the Exclude property:
using System.Reflection;
// this class name won't be obfuscated
[Obfuscation] // it's the same as [Obfuscation(Exclude = true)]
internal class MyHelper
{
}
Please note that the default value for the Exclude
property is true
, which excludes it from being obfuscated. Though it might look confusing when arguments are ommitted.
Project config
Example decoded json config in project file:
{
"namingStrategy": 0,
"filteringStrategy": 1,
"configFile": "obfuscation.xml"
}