Asset Layer Docs
Asset LayerAPI Docs
  • 👋Welcome
  • Getting Started
    • Quick Start
      • Quick Start for Developers
      • Quick Start for Creators
      • Quick Start for Unity
    • Core Concepts
      • Users
      • Auth + Permissions
      • Teams
      • Apps
      • Slots
      • Expressions
      • Assets + Collections
      • Currencies
      • Marketplace and Shops
      • Core Concepts in Action
    • SDK Docs
      • Setup
      • Users
        • getUser()
      • Apps
        • info()
        • getApp()
        • getApps()
        • slots()
        • getAppSlots()
        • getAppSlotIds()
      • Slots
        • getSlot()
        • collections()
        • getSlotCollections()
        • getSlotCollectionIds()
        • getSlotExpressions()
        • createExpression()
        • updateExpression()
        • getExpressionTypes()
      • Collections
        • info()
        • getCollection()
        • getCollections()
        • assets()
        • getCollectionAssets()
        • getCollectionAssetIds()
        • createCollection()
        • updateCollection()
        • updateCollectionImage()
        • activateCollection()
        • deactivateCollection()
      • Assets
        • info()
        • getAsset()
        • getAssets()
        • user()
        • getUserAssets()
        • getUserAssetIds()
        • getUserAssetCounts()
        • getUserCollectionAssets()
        • getUserCollectionsAssets()
        • getUserSlotAssets()
        • getUserSlotsAssets()
        • mintAssets()
        • send()
        • sendAsset()
        • sendAssets()
        • sendCollectionAssets()
        • sendLowestAsset()
        • sendRandomAsset()
        • update()
        • updateAsset()
        • updateAssets()
        • updateCollectionAssets()
        • expressionValues()
        • updateAssetExpressionValue()
        • updateAssetsExpressionValue()
        • updateCollectionAssetsExpressionValue()
        • updateBulkExpressionValues()
      • Equips
        • getEquips()
        • setEquip()
        • removeEquip()
      • Currencies
        • info()
        • getCurrency()
        • balance()
        • getCurrencyBalance()
        • getCurrencySummary()
        • increaseCurrencyBalance()
        • decreaseCurrencyBalance()
        • transferCurrency()
      • Listings
        • getListing()
        • user()
        • getUserListings()
        • getUserListingsCounts()
        • getUserCollectionListings()
        • getUserCollectionListingsCounts()
        • getUserSales()
        • getUserSalesCounts()
        • getUserPurchases()
        • getUserPurchasesCounts()
        • collection()
        • getCollectionListings()
        • getCollectionsListings()
        • getCollectionListingsCounts()
        • getCollectionsListingsCounts()
        • getCollectionListingsStats()
        • getCollectionsListingsStats()
        • app()
        • getAppListings()
        • getAppListingsCounts()
        • getAppListingsStats()
        • new()
        • listAsset()
        • listAssets()
        • listCollectionAssets()
        • updateListing()
        • buyListing()
        • removeListing()
      • Shop
        • buyItem()
        • summary()
      • Core Types
        • User
        • App
        • Slot
        • Expression
        • Collection
        • Asset
        • Equip
        • Currency
        • Listing
        • Shop
        • Basic
      • SDK Repo
      • C# SDK for Unity
    • Guides
      • How to Integrate Asset Layer into your Unity Game
    • API Docs
    • Asset Layer GPT
  • Build an app
    • App Setup
      • Creating an App
      • Managing Apps
      • App Info
      • Manage Permissions
      • Manage Slots
      • Manage Collections
      • Manage Currencies
      • App Settings
    • App Development
    • Build With Unity
      • Unity App Setup
      • Advanced Unity Setup
        • WebGL App Setup
      • Asset Layer Unity SDK
        • Login + Authentication
        • Create Assets in Unity
        • Import Assets Into Your Scene
        • Inventory Manager
        • Sync Your Assets
        • Asset Layer Game Server
        • C# SDK
    • Sample App
      • Getting Started With Sample App Locally
      • Environment Variables
      • API Routes
      • Deployment
      • Default Pages
      • Deploying Your Unity WebGL Game Through Sample App
  • Create and Manage Assets
    • Create Assets With Code
    • Create Assets Without Code
      • Create Assets for My App
      • Submit a Collection for a 3rd Party App
      • Create an Independent Collection - Coming Soon!
    • Create Assets in Unity
    • Managing Collections from 3rd Party Creators
  • Manage Assets
    • My Assets
      • Listing Assets for Sale
      • Sending Assets as a Gift
      • My Listings
      • Marketplace History
    • Marketplace
  • Settings
    • Team Settings
    • Account Settings
    • Pricing
  • Details
    • Expression Types
      • Image
      • Audio
      • Video
      • Unity
      • Spine 4.0 (2D Animated Characters)
      • Additional Expression Types
Powered by GitBook
On this page
  1. Build an app
  2. Build With Unity
  3. Asset Layer Unity SDK

Login + Authentication

PreviousAsset Layer Unity SDKNextCreate Assets in Unity

Last updated 1 year ago

The Asset Layer Unity SDK comes with a scene called LoginScene which is used to handle player authentication. The scene is designed to work regardless of platform (browser, mobile, or desktop). However, the way in which authentication occurs varies based on platform. Please see the sections below for details.

To find the LoginScene, first make sure you have imported the essentials package Unity App Setup. Then, you'll see the LoginScene in Assets/AssetLayerUnitySDK/Scenes. You can customize the LoginScene per your requirements.

The LoginScene contains a GameObject called AssetLayerLogin. The AssetLayerLogin contains a child GameObject called LoginReceiver. You can set the scene to load upon a successful login in the LoginReceiver. Make sure that the LoginScene and any other scenes in your project are included in your build.

WebGL Login

In a browser based context, authentication should happen through the website into which the WebGL build is integrated. The Login Scene remains inactive until the SetDidToken method of the LoginReceiver GameObject is called. This method is designed to be triggered from the web environment, allowing messages to be sent to specific GameObjects within the Unity WebGL build. To ensure smooth operation, it is crucial to verify that Unity has fully loaded the Login Scene before sending any messages. You can facilitate this by setting the Login Scene as the initial scene in your Unity application and confirming that the Unity startup process has completed prior to message transmission.

You can view more details on sending messages between your web app and WebGL Unity environments in the following sections:

Deploying Your Unity WebGL Game Through Sample App

Desktop Login

For desktop builds, the login scene will provide a button that when clicked will open a webpage where the user can login.

This webpage can be set in the Asset Layer section of the project settings under "Login URL". That page will then return the DID token to the Unity app. Upon clicking the login button, the Login Scene initiates a local HttpServer. For web login, a Get Request containing the Did Token should be sent to http://localhost:8080/loginUnity/, appending a token parameter. Following the reception of this request, the token undergoes a validity check. If valid, the scene specified in the LoginReceiver GameObject will be loaded.

Mobile Login

For mobile login, users are able to generate their DID token within the app. The LoginScene prompts users for their email address and then the user is sent a one-time passcode. Once the passcode is entered correctly, the DID token is generated and the scene specified in the LoginScene is loaded.

Sending a Message to Unity