Eternals
  • Introduction
  • Eternia
    • Lore
    • Creatures System
      • Legend
      • Elementals
        • Fire
        • Nature
        • Earth
        • Water
        • Metal
      • Base Eternals
    • Space Stone
  • Alliance Mining Program
    • Getting Started
    • User Profile (Alliance Center)
      • Upgrade Account
      • Achievements
    • Mechanism
    • Reward Distribution
  • $ETNS (Eternals Stars Program)
    • The $ETNS System
  • Eternals Core
    • Eternals House
      • Mood
      • How to maintain a good pet's mood?
      • Decoration
      • Shop
    • Eternals Space
      • Missions
      • Mining Tower
      • Leaderboard
      • Refill Plasma
  • Eternals World
    • Gomoku
      • Game modes: Classic and Eternians
      • Battle Deck
      • Quick Match
      • Ranking Match
      • How to earn Tickets
      • How to join Eternals Gomoku
      • Missions
      • Daily Login
      • Mastery Points
      • Win Streak
      • Pet Skills
      • Leaderboard and Reward Pools
  • ETER Token
  • How To Earn With Eternals?
  • Official Links
    • Website
    • Twitter
    • Discord
    • App Store
    • Google Play
  • GDK Documentation
    • Ninety Eight Game Development Kit
    • Introduction
    • Unity
      • GDK Installation Guide
      • Update Guide
      • Examples
      • Downloads
      • Release Notes
      • API Reference
        • v1.0.0
          • NinetyEight.INEGdk
          • NinetyEight.ErrorCode
          • NinetyEight.NEGameProfile
          • NinetyEight.NEGameProfileCallback
          • NinetyEight.NEGameProfileResponse
          • NinetyEight.NEGdkConfig
          • NinetyEight.NEInitCallback
          • NinetyEight.NELoginCallback
          • NinetyEight.NELoginData
          • NinetyEight.NEProvider
          • NinetyEight.NEShopBuyCallback
          • NinetyEight.NEShopBuyResponse
          • NinetyEight.NEShopInfoCallback
          • NinetyEight.NEShopInfoResponse
          • NinetyEight.NEShopItem
          • NinetyEight.NEShopPack
          • NinetyEight.NEUserBalance
          • NinetyEight.NEUserBalanceCallback
          • NinetyEight.NEUserBalanceResponse
          • NinetyEight.NEUserPet
          • NinetyEight.NEUserPetCallback
          • NinetyEight.NEUserPetResponse
          • NinetyEight
    • Cocos Creator
      • Installation Guide
      • Update Guide
      • Examples
      • Downloads
      • Release Notes
      • API Reference
        • NinetyEight Game Development Kit - Cocos Creator
          • Enumerations
            • NinetyEight.NEEnvironment
            • NinetyEight.NEErrorCode
            • NinetyEight.NEProvider
          • Interfaces
          • Type-aliases
            • NEGameProfile
            • NEGameProfileCallback
            • NEGameProfileResponse
            • NEGdkConfig
            • NEInitCallback
            • NELoginCallback
            • NELoginData
            • NEShopBuyCallback
            • NEShopBuyResponse
            • NEShopInfoCallback
            • NEShopInfoResponse
            • NEShopItem
            • NEShopPack
            • NEUserBalance
            • NEUserBalanceCallback
            • NEUserBalanceResponse
            • NEUserPet
            • NEUserPetCallback
            • NEUserPetResponse
  • LEGAL
    • Game Terms of Use
    • Privacy Policy
    • Terms of Use
Powered by GitBook
On this page
  • Initialize the GDK
  • Login
  • Social Login
  • Get User Pets Data
  • Get User Balances Data
  • Get Shop Info
  • Buy a Pack in the shop
  1. GDK Documentation
  2. Unity

Examples

You can check outthe example code in the package at Assets/NEGdk/Sample/NEGdkSample.ts

Initialize the GDK

NEGdk.Instance.Initialize((errorCode) => {
    if (errorCode == 0) {
        // Init success
        if (NEGdk.Instance.IsLoggedIn()) {
            // Already login using cache, you can fetch user data now
        } else {
            // Not login yet
        }
    } else {
        // Init failed
    }
});

Login

Social Login

NEGdk.Instance.LoginWithProvider("google", (errorCode, loginData) => {
    if (errorCode == 0) {
        // Login success
        var profile = loginData.profile;
    } else {
        // Login failed
    }
});

Create/Restore Wallet

var phrase = NEGdk.Instance.CreateWallet();
NEGdk.Instance.LoginWithPhrase(phrase, (errorCode, loginData) => {
    if (errorCode == 0) {
        // Login success
        var profile = loginData.profile;
    } else {
        // Login failed
    }
});

Logout

NEGdk.Instance.Logout();

Get User Pets Data

NEGdk.Instance.RequestUserPets((response) => {
    if (response.errorCode == 0) {
        // get user pets success
        var pets = response.data;
    } else {
        // get user pets failed, check errorCode for reason
    }
});

Get User Balances Data

NEGdk.Instance.RequestUserBalances((response) => {
    if (response.errorCode == 0) {
        // get user balances success
        var balances = response.data;
    } else {
        // get user balances failed, check errorCode for reason
    }
});

Get Shop Info

NEGdk.Instance.RequestShopinfo((response) => {
    if (response.errorCode == 0) {
        // get shop info success
        var shopPacks = response.data;
    } else {
        // get shop info failed, check errorCode for reason
    }
});

Buy a Pack in the shop

var packId = 26;
var amount = 1;
var currency = "SPACE_STONE";
NEGdk.Instance.BuyShopPack(packId, amount, currency, response => {
    if (response.errorCode == 0) {
        // Buy success
        var remainBalance = response.data;
    } else {
        // Buy failed, check error code for reason
    }
});

PreviousUpdate GuideNextDownloads

Last updated 24 days ago