UNITY

Quick Start

Download the Latest Version

1. Project Settings

Set the development environment as shown in the following in Unity in order to use NaverGame SDK.

This guideline has been written with respect to version Unity2019.4.20f

  • Click Asset > Import package from Unity’s menu, then select the NaverGameSDK-x.x.x.unityPackage file downloaded from the Custom Package conversation box.

  • Once you click Import from the Custom Package conversation box the NGSDK folder and the Plugins folder will be generated.

  • A standard run button is included inside the SampleScene file contained in the NGSDK Folder’s Sample folder. If the Unity versions are different, SampleScene might not load properly. In this case, refer to the following guideline to configure a new UI.

Generate button on canvas.

  • Click on GameObject > UI > Canvas to generate UGUI Canvas.

  • Drag SampleButton.Prefab within the Sample folder in the NGSDK under the generated Canvas. A standard button provided by NaverGameSDK is generated.

  • For convenience, the NaverGame SDK run button can be generated using the standard button provided by NaverGame SDK. The sample code is written in the SampleBehaviour.cs file.

  • NaverGame SDK’s run button is written based on Unity’s UGUI. In the case that UGUI is not used or that a different library is used, it may be used while referring to the SampleBehaviour.cs file.

Detailed information regarding the NaveGame SDK with respect to different operating systems will be referenced on GitHub Storages.

2. Additional Settings for Android

For NAVER Game SDK to support Android 12 (API level 31) or more, versions such as Unity 2020 or higher must be installed. Also, to support Android 11 (API level 30), additional settings are required in the Unity 2019 version.

2-0. minSdkVersion Settings

minSdkVersion must be set to 21 or over.

mindSdkVersion has been set to 19 for library compatibility, but because of targetSdk30 Issue (https://github.com/square/okhttp/issues/5162) of OKHttp 3.14.7, version 21 or above needs to be used.

Additional settings are required to support versions below 21, and these can only be supported in the Gradle build.

Please refer to the relevant link in the Android guide for information on settings for versions below 21.

2-1. Unity 2019.4.20f

Since the 1.2.0 version of the Android Library, public package status element has been added to support Android 11 (API level 30). In order to compile the public package status <queryies> element, Gradle version 5.6.4 or higher is required.

Android Gradle Plugin version for Gradle version 5.6.4 is version 3.6.0. To view the compatibility of Android Gradle plugin and Gradle version that you are currently using, please refer to the Android Gradle plugin compatibility table.

Please see the following for Gradle and Android Gradle Plugin settings.

2-1-1. Gradle Version 5.6.4 Settings

Go to Preferences > External Tools > Android > Gradle Installed with Unity. Delete the option and select custom version of 5.6.4 or above. For information on custom version downloads, please refer to the Gradle build tool.

2-1-2. Android Gradle Plugin Settings

Go to Project Settings > Player > Android Tab > Publishing Settings > Build, and select Custom Main Gradle Template, Custom Base Gradle Template, and Custom Gradle Properties Template.

Once the options are selected, the baseProjectTemplate.gradle file should have been generated in Assets/Plugins/Android folder. Open this file using the editor, delete the com.android.tools.build.gradle:3.4.0 item under dependencies, and edit this to 3.6.0 or higher, as shown below.

dependencies {
    classpath 'com.android.tools.build:gradle:3.6.4'
    **BUILD_SCRIPT_DEPS**
}

Once you’ve gotten this far, Gradle setup is complete. The mainTemplate.gradle and gradleTemplate.properties files also need to be set in Unity 2020 or higher versions, and these will be explained in the next section.

2-2. Unity 2020 or Higher

To support Android 12+(API level 31) or higher, Navergame SDK versions after 1.2.0 only support Gradle universal library. In order to use Gradle universal library, you need to add the dependency through the Custom Gradle settings.

Go to Project Settings > Player > Android Tab > Publishing Settings > Build and select Custom Main Gradle Template and Custom Gradle Properties Template.

Once the options are selected, mainTemplate.gradle file should have been generated in Assets/Plugins/Android folder. Open this file using the editor, and add a subordinate library under dependencies.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "com.naver.nid:naveridlogin-android-sdk:4.2.6" // naveridlogin
        implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.20"      // Kotlin
        implementation "androidx.viewpager2:viewpager2:1.0.0"           // Viewpager2
        implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"   //swiperefreshlayout
        implementation "com.github.bumptech.glide:glide:3.7.0"          // Glide
        implementation "com.squareup.retrofit2:retrofit:2.9.0"          // Retrofit2
        implementation "com.squareup.retrofit2:converter-gson:2.9.0"
**DEPS**}

From versions 1.2.0 onwards, naveridlogin-android-sdk has been added for writing purposes, and kotlin-stdlib, retrofit, converter-gson versions have been changed. Please keep this in mind when upgrading from the 1.x.x version.

Also, open gradleTemplate.properties item and add the android.useAndroidX, android.enableJetifier items as true.

android.useAndroidX = true
android.enableJetifier=true
**ADDITIONAL_PROPERTIES**

2-3. Minify Settings

Complete the Minify(proguard) setup for the Release build.

  • Go to Build Settings > Player Settings > AndroidTab > Publishing Settings and select Custom Proguard File setting to create a new proguard-user.txt file.

  • Activate Release at Build Settings > Player Settings > AndroidTab > Publishing Settings > Minify.

  • Open proguard-user.txt file and add the following proguard settings.


#retrofit 2

# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions


#end of retrofit2

#gson
##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }



# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

##---------------End: proguard configuration for Gson  ----------
#end of gson

#glide
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}
#end of glide

#kotlin
-keep class kotlin.** { *; }
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
    <fields>;
}
-keepclassmembers class kotlin.Metadata {
    public <fields>;
    public <methods>;
}
#End of kotlin


#navergame sdk
# Application classes that will be serialized/deserialized over Gson
-keep class com.navercorp.nng.android.sdk.api.Host** { *; }
-keep class com.navercorp.nng.android.sdk.api.service** { *; }
-keep class com.navercorp.nng.android.sdk.api.entity** { *; }

-keep class com.navercorp.nng.android.sdk.NngNdkWrapper** { *; }
-keepclassmembers class com.navercorp.nng.android.sdk.NngNdkWrapper { *; }

-keep class com.navercorp.nng.android.sdk.NNGLink** { *; }
-keep class com.navercorp.nng.android.sdk.NNGLink$Companion { *; }
-keepclassmembers class com.navercorp.nng.android.sdk.NNGLink {
    public static ** Companion;
}
-keep public interface com.navercorp.nng.android.sdk.NNGCallbackListener {*;}
-keep class com.navercorp.nng.android.sdk.NNGConfig** { *; }


#end of sdk

3. Additional Settings for IOS

Naver Game iOS SDK supports iOS versions 12.0 and above.

Additional items such as the following have to be set when developing an iOS game.

When building applications for iOS for versions above Unity 5.4.0f3, the. bundle file is set to not become linked. iOS must be selected from Select for platforms for plugin as shown in the following so that it may link the NNGSDK.bundle

2-2. Xcode Settings

Set the development environment as shown in the following in Xcode.

  • Select framework from the TARGETS category.

  • Select the Build Setting tab and find Other Linker Flags from the Linking category.

    • If in either of Basic or Customized modes, the Other Linker Flag might not appear, and in this case select All mode .

    • It can be easily found by entering Other Linker Flags into the search bar located in the upper right corner.

  • Add the -ObjC option and the -lc++ option to Other Linker Flags.

  • Add the following option to obtain user permission to Info.plist.

    • Privacy - Camera Usage Description

    • Privacy - Photo Library Usage Description

  • Select the app that is going to be run amongst the TARGETS category, and input the Identifier values and URL Schemes values into the URL Types category of the Info tab.

  • The Identifier value can be checked from the General tab of the relevant TARGET.

  • For the URL Schemes value , input the URL Scheme value that was used to register for the application in the developers center after logging in with a Naver Id.

  • Add SafariServices.framework and NaverLogin.framework at Build Phases -> Link Binary With Libraries.

Using NaverGameSDK

The init method has to be called for before using the NaverGameSDK.

init() method

The init() method is the method that sets the NaverGameSDK. The factors needed are as follows.

  • loungeId: The Lounge Id received after requesting for the official lounge.

  • clientId: The Client Id received after registering the application at the developers center after logging in with a Naver Id.

  • clientSecret: The client secret received after registering the application at developers center upon logging in with a Naver Id.

public void init(string loungeId, string clientId, string clientSecret);

The following example is a demonstration of the implementation of the init() method.

GLink.sharedInstance().init(
    "naver_game_4developer", 
    "UKvNABLDsyEJusJGsXL2",
    "rK4suc_Qd0"
    );

terminateSdk() method

The TerminateSdk() method is the method that terminates the NaverGameSDK. It is called in when the sdk has to be terminated under certain circumstances. For example, when running an in-game menu code that is delivered through GLinkDelegate callback, the TerminateSdk() method must be called to terminate the sdk.

void terminateSdk();

The following example is a demonstration of the implementation of the terminateSdk() method.

Glink.sharedInstance().terminateSdk()

executeHomeBanner() method

The method that displays a registered banner window.

public void executeHomeBanner()

The following example is a demonstration of the implementation of the executeHomeBanner() method.

Glink.sharedInstance().executeHomeBanner()

executeSorryBanner() method

Posts a specific notification or a notification for maintenance. From this page, transitions to other pages is limited.

public void executeSorryBanner()

The following example is a demonstration of the implementation of the executeSorryBanner() method.

Glink.sharedInstance().executeSorryBanner();

executeBoard(int boardId) method

This method immediately runs a certain board. BoardId can be found in the URL shown when accessing the board through the web, in the form of https://game.naver.com/lounge/{loungeId}/board/{boardId}.

public void executeBoard(int boardId);

The following example is a demonstration of the implementation of the executeBoard() method.

Glink.sharedInstance().executeBoard(1);

executeFeed(long feedId, bool isTempFeedId) method

The method that runs using the number of the registered post. In the case for scheduled notification post that have scheduled through scheduled exposure, the number of the scheduled post must be inputted into FeedId and the IsTempFeedId must be inputted as True. Before the scheduled post is posted, running the method does not lead to the exposure of the post.

  • FeedId: The number of the notification post or the scheduled notification post.

  • IsTempFeedId: Remains false if the FeedId is a notification post and remains true if the FeedId is a scheduled notification post.

void executeFeed(long feedId, bool isTempFeedId);

The following example is a demonstration of the implementation of the executeFeed() method.

Glink.sharedInstance().executeFeed(50154, true);

executeFeedWriting(int boardId, string title, string text, string imageFilePath) Method

This method runs the writer page. BoardId is the board number, Title is the title of the writing, Text is the content of the writing, and ImageFilePath is the path of the attached image. Only one image may be attached.

Not all parameters are necessary. If entered, they will be set in the writer page in advance.

  • boardId: This is the board number. This can be found in the URL shown while accessing the board through the web, in the form of https://game.naver.com/lounge/{loungeId}/board/{boardId}.

  • title: This is the title of the writing.

  • text: This is the text to be added to the main body.

  • imageFilePath: This is the LocalPath of the image to be attached. In Android, there is a process of obtaining image rights, so if this value is manually entered, it needs to be checked thoroughly.

void executeFeedWriting(
int boardId, String text, String text, String imageFilePath);

The following example is a demonstration of the implementation of the writeFeed() method.

  Glink.sharedInstance().executeFeedWriting(54,"제목 테스트","본문테스트",
  "content://com.example.contentprovidersample.provider/cheeses")

setCanWriteFeedByScreenshot(bool enabled) Method

This method shows a button for writing by detecting when a user has taken a screenshot. When not summoned, the base value is ON (true).

  • If enabled: true, writing button appears when a screenshot is captured.

void setCanWriteFeedByScreenshot(bool enable);

The following example is a demonstration of the implementation of the enableScreenShotDetector() method.

  Glink.sharedInstance().setCanWriteFeedByScreenshot(true)

setGameId(string gameId) Method

This method syncs with NAVER Login and matches the user and their NAVER ID. This can be used to confirm the game ID of users that win event draws through posts and comments.

This called be called at any point after the init function is called.

  • gameId: Input an identifiable game ID. Only one game ID is saved for one NAVER ID.

void setGameId(string gameId);

The following example is a demonstration of the implementation of the setGameId() method.

  Glink.sharedInstance().setGameId("your_game_id_for_test")

getCountryCode() method

Obtain the countryCode of the device.

public string getCountryCode(Activity activity);

The countryCode is the country code (ISO 3166-1 alpha-2) composed of two alphabets. This enables branch processing by countries within the codes. The notable country codes are as shown in the following. Refer to the link for other country codes.

Country Code

Country

CN

China

JP

Japan

KR

Republic of Korea

TH

Thailand

US

United States of America

The following is an example of using the getCountryCode() method to reset the SDK exclusively for Korea.

if (GLink.sharedInstance().getCountryCode().Equals("KR"))
{
    GLink.sharedInstance().init("LoungeId","ClientId","ClientSecret");
    GLink.sharedInstance().executeHomeBanner();
}

GLinkDelegate Delegate

When a specific event occurs within the SDK, using said event, the GameEngine is notified.

SdkOpenedDelegate Event

Occurs when NaverGameSdk is running.

public delegate void SdkOpenedDelegate();
public static event SdkOpenedDelegate sdkOpenedEvent;

The registration method is as follows.

private void Awake()
{
    GLinkDelegate.sdkOpenedEvent += SdkOpenedEvent;
}
void SdkOpenedEvent()
{
    Debug.Log("BannerOpenedEvent");
}

SdkClosedDelegate Event

Occurs when NaverGameSdk has been terminated.

public delegate void SdkClosedDelegate();
public static event SdkClosedDelegate sdkClosedEvent;

The registration method is as follows.

private void Awake()
{
    GLinkDelegate.sdkClosedEvent += SdkClosedEvent;
}
void SdkClosedEvent()
{
    Debug.Log("BannerClosedEvent");
}

SdkCallInGameMenuCode Delegate

Occurs when the in-game menu code has to be run in NaverGameSdk. Used when an 'In-Game Menu’ has been registered on the banners of Official Lounge Maintenance Page> SDK Maintenance> Banner Maintenance pages. Depending on the Android and iOS platforms, the registered values are delivered independently, so if different values have been inputted, they must be processed independently.

public delegate void SdkCallInGameMenuCode(string InGameMenuCode);
public static event SdkCallInGameMenuCode sdkCallInGameMenuCode;

The registration method is as follows.

private void Awake()
{
    GLinkDelegate.sdkCallInGameMenuCode += SdkCallInGameMenuCode;
}
void SdkCallInGameMenuCode(string inGameMenuCode)
{
    GLink.sharedInstance().terminateSdk();
    Debug.Log("SdkCallInGameMenuCode " + inGameMenuCode);
}

Build

The SDK is usable once proper building according to the respective platform is complete.

1. Build Errors that may Occur

1-1 Andorid Build Error

Horizontal Mode, Vertical Mode

Naver Game SDK supports both horizontal and vertical modes.

Under both Android and iOS environments, the horizontal mode and the vertical mode is applied automatically according to the screen’s horizontal and vertical orientation without the need of additional settings.

Last updated

Was this helpful?