Unity Obfuscator - Renaming option

Unity Obfuscator - Renaming option


Rename option includes a conversion mechanism names of classes, methods, properties, fields, events into a set of meaningless characters.


Renaming mechanism names complicates the study of the program logic.


But to save the code functionality - not all the names, you can rename, especially the Unity environment, this in DevXObfuscator obfuscator automatic create rules, exceptions for some names:



  1. Of the renaming process excluded class names inherited from the unity MonoBehaviour and ScriptableObject

    reason: In Unity classes inherited by MonoBehaviour or ScriptableObject used in the scene for GameObject objects, and made a bunch of class name, so changing the name of the class - Unity will not be able to associate a link in GameObject with real class in the assembly (dll).


    example:
    // for obfuscator - Dont rename ‘GameObjectScript’
    public class GameObjectScript : MonoBehaviour
    {
    }

  2. Out renaming process excluded names of the following functions (for classes inherited from MonoBehaviour)

    Create, Update, LateUpdate, FixedUpdate, Awake, Start, Reset, OnMouseEnter, OnMouseOver, OnMouseExit, OnMouseDown, OnMouseUp, OnMouseDrag, OnTriggerEnter, OnTriggerExit, OnTriggerStay, OnCollisionEnter, OnCollisionExit, OnCollisionStay, OnControllerColliderHit, OnJointBreak, OnParticleCollision, OnBecameVisible, OnBecameInvisible, OnLevelWasLoaded, OnEnable, OnDisable, OnPreCull, OnPreRender, OnPostRender, OnRenderObject, OnWillRenderObject, OnGUI, OnRenderImage, OnDrawGizmosSelected, OnDrawGizmos, OnApplicationPause, OnApplicationQuit и некоторые другие..


    reason: Unity in the process calls certain class methods whose names are reserved for certain actions, for example Update is called when updating each scene and if we rename it, Unity will not find by name this method and the function will not be called.

    example:
    // for obfuscator - Dont rename ‘GameObjectScript’
    public class GameObjectScript1 : MonoBehaviour
    {
    // for obfuscator - Dont rename
    // Use this for initialization
    void Start ()
    {  
    }

    // for obfuscator - Dont rename
    // Update is called once per frame
    void Update ()
    {
    }
    }




  3. Because the renaming process excluded the names public "public" classes, methods, properties, fields.


    reason: carried out by name, so for example, if you rename a field in the class that Unity does not find it, it will cause an error in the game scene for objects GameObject can use the fields and methods of classes, but a bunch.  

    example:
    // for obfuscator - Dont rename ‘GameObjectScript’
    public class GameObjectScript : MonoBehaviour
    {
       // for obfuscator - Dont rename
       public string field_for_scene;

       // for obfuscator - Dont rename
       public bool flag_for_scene;


       // for obfuscator - allow rename
       internal string name_for_only_scripts_access;
       // for obfuscator - allow rename
       private bool flag_for_only_class_access;

       // for obfuscator - allow rename
       protected int count_for_only_class_access;
    }


  4. Because of the renaming process excluded the names of serialized classes of their properties and fields.


    Reason: In the process of serialization classes used the names of their fields and properties, so if you rename a class, the serialization may fail.  

    Example:
      // for obfuscator - Dont rename class and contents
       [System.Serializable]
       class TestObject
       {
           string name;
           int count;
       }


Recommendation


It to obtain is recommended to follow the following rules the maximum effect of the obfuscation process:

  1. Use the "public" modifier only where it is really needed, in other cases, replace with:

    1. "internal"- The type or member can be accessed by any code in the same assembly, but not from another assembly.

    2. "protected"- The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.

    3. "private"- The type or member can be accessed only by code in the same class or struct.

  2. Game logic better display of the classes inherited from MonoBehaviour in some internal classes without modifying public and serialization flag, so it is much more difficult to link the logic of the objects in the scene.

  1. If you want to exclude some or classes, methods, properties, fields, events, you can use:

    1. DevXUnity_DoNotObfuscateAttribute attribute is to be excluded from the process of renaming

      Example:
         // for obfuscator - Dont rename class and contents
         [DevXUnity_DoNotObfuscate()]
         class TestObject
         {
            [DevXUnity_DoNotObfuscate()]
             string name;
             int count;
         }

    2. Alternatively, you can specify exceptions in the interface in the Settings section, listing the names of classes, methods .. or script names.


 

 

 
19.05.2017