Advanced Protection for Unity

Encrypt your code through the Advanced Protection.

1. Requirements

Please ensure that the following programs are installed prior to proceeding with this tutorial.

  • Unity Installed: version 4.6 or later
  • Android SDK Installed: API 8 or later / Android SDK build-tools revision 19.1 or later
  • AppSealing Unity Extension

2. Setup

2.1 Recommendation

It is recommended that you try implementing AppSealing with a sample project before continuing to your own project. 

2.2 Import project to Unity

  1. Launch Unity
  2. Click the ‘Open’ button
  3. Select the project folder and import to Unity.
  4. When the project has been completely imported, Assets are created in the Unity.

2.3 Install AppSealing Unity Extension

  1. Download the Unity Extension.
  2. Install the downloaded Unity Extension.
    • Path: ‘Assets’ menu > ‘Import Package’ > Click the ‘Custom Package’ 
  3. Find the folder path of the downloaded Unity Extension and double click the file or open it.
  4. Click the ‘Import’ button.
  5. ‘AppSealing’ menu is created in the upper part of Unity when the import has been completed.

3. AppSealing Tagging

3.1 Start AppSealing

  1. Click the ‘Create AppSealing Attribute Class’ to start AppSealing. (Fig.1)
    • Path: ‘AppSealing’ menu > Click the ‘Create Attribute Class’
  2. The following folders are added to the ‘Assets’ folder :
    • Assets/AppSealing
    • Assets/Editor/AppSealing/
  3. AppSealing Instructions will be displayed. (Fig. 2)
  4. Please read the instructions before proceeding to the next step.

(Fig. 1)



3.2 AppSealing Tagging

AppSealing tagging (declaring attribute) needs to be done to the code in order for protection. In this tutorial tagging means declaring the attribute. There are three types of tag that can be added to protect the code. The following steps will instruct on how to add each tags to the code by different situations.

3.2.1 Class Protection

Declare [AppSealingSecurityClass] attribute in each class that you wish to protect. Use this to protect the whole class. Please take reference of the attribute declared on (Fig. 3).

(Fig. 3)

3.2.2 Method Protection

Declare [AppSealingSecurityMethod] attribute in each method that you wish to protect. Use this if you wish to protect a certain method, but not the class. Please take reference of the attribute declared on (Fig. 4).

(Fig. 4)

3.2.3 Exclude Specific Method from Protection

Declare [AppSealingSecurityNotApply] attribute in each method to exclude from protection. Use this to allow better app performance. Please take reference of the attribute declared on (Fig. 5).

(Fig. 5)

3.3 Important Guideline

  • It is highly recommended that the attribute is declared in the Awake or Start method of the first Scene.
  • Inner classes and methods needs to be tagged additionally in order to protect them.
  • Using C# name obfuscation can cause compatibility issue with AppSealing.
  • Encrypting Assembly-CSharp.dll file will cause Sealing to fail.
  • The following methods are not encrypted by AppSealing, please move the important code to a separate method and call the method.
    • Coroutine method
    • Anonymous method and lamda expression
    • Method using lock or System.Threading.Monitor
    • Abstract class
  • For optimal performance, it is recommended that the following methods are excluded from protection:
    • Update method of Scene or other methods called from Update
    • 3rd party methods (ex. Google Play Login, Facebook, Twitter etc...)
    • Methods that are called frequently during execution

NOTE: The game must run properly on Unity after tagging has been done. If the game does not run then check the tagging or the game logic.

  1. Click the play button on Unity. (Fig. 6)
  2. Proceed to next step if the game runs properly.

(Fig. 6)

3.4 Build APK File

  1. Use the build function in Unity to build the APK file of the project.
    • Path: Ctrl+Shift+B or ‘File’ > Click ‘Build Settings…’
  2. Build Setting panel is displayed.
  3. Click ‘Build’ button.
  4. Set the APK file name and save path.
  5. APK file is created.

4. Sealing APK

Sealing on the APK is required to activate the security module. Please upload the APK file on the Developer Console page.

Sealing Tutorial Link : Sealing Tutorial

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request
comment section


Article is closed for comments.