Unity SDK Prerequisites
Integrate powerful Web3.0 Unity SDK in minutes
Prerequisites
Install Unity 2020.3.26f1 or later. Earlier versions may also be compatible but will not be actively supported.
(iOS only) Install the following:
Xcode 14.1 or higher
CocoaPods 1.12.1 or higher
Make sure that your Unity project meets these requirements:
For iOS — targets iOS 14 or higher
For Android — Minimum API Level 23 or higher, Targets API level 33 or higher, Pack apk must be with exporting project to Android Studio, change Java SDK version to 11
Create a Particle Project and App
Before you can add our Auth Service to your Unity game, you need to create a Particle project to connect to your iOS and Android app. Visit Particle Dashboard to learn more about Particle projects and apps.
👉 Sign up/log in and create your project now
Import Unity package
Download and import the Unity package
https://github.com/Particle-Network/particle-unity/releases
iOS
Configure scheme url in Unity Editor
Open the iOS Player Settings window (menu: Edit > Project Settings > Player Settings, then select iOS).
Select Other, then scroll down to Configuration.
Expand the Supported URL schemes section and, in the Element 0 field, enter the URL scheme to associate with your application. For example, if your project app id is "63bfa427-cf5f-4742-9ff1-e8f5a1b9828f", your scheme URL is "pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f"
Remove other service code if you don't need them.
In ParticleNetworkIOSBridge.cs, there are 6 part ParticleNetworkBase, ParticleAuthService, ParticleWalletGUI, ParticleConnect, ParticleAA, ParticleAuthCore, works for interact with iOS native. ParticleNetworkBase is required,
ParticleAuthService if required for Auth Service,
ParticleConnect is required for Connect Service.
You can remove other codes if you don't need them.
Configure Xcode project after iOS build.
Create a Podfile if you don't already have one. From the root of your project directory, run the following command:
To your Podfile, add select these pods that you want to use in your app:
Install the pods, then open your
.xcworkspace
file to see the project in Xcode:
Configure Project information.
Create a ParticleNetwork-Info.plist into the root of your Xcode project
Copy the following text into this file:
3. Replace YOUR_PROJECT_UUID
, YOUR_PROJECT_CLIENT_KEY
, and YOUR_PROJECT_APP_UUID
with the new values created in your Dashboard
Android
Configuration file path is Assets/Plugins/Android/gradleTemplate.properties
Android, iOS Native Service Config
Android — Configuration file path is Assets/Plugins/Android/launcherTemplate.gradle
iOS
Download
UnityManger.swift
,Unity-iPhone-Bridging-Header.h
andAppDelegate.swift
from under github/Assets/Plugins/iOS/.Swift
, Copy files into the root of your Xcode project. Xcode will ask you if auto create Bridging file, click yes.
2.Make sure Build Settings, Swift Compiler - General, has Objective-C Bridging Header, its connect is Unity-iPhone-Bridging-Header.h 's local path.
3. Remove main.mm
under MainApp folder.
4. Under /Assets/Plugins/iOS
is NativeCallProxy files, they are requested by Unity to interact with iOS code. Remove code under Particle Wallet GUI if you don't need wallet service.
5. In UnityManger.swift
, it has implemented methods defined in NativeCallProxy.h
6. Select NativeCallProxy.h, in the file inspector, check public in Target Membership.
7. If you want to use ParticleConnect, you should add LSApplicationQueriesSchemes to info.plist.
8. If you are skilled in iOS, you can modify these files as you like. For example, add other services.
FAQ
Unity Editor
In demo, after login tap Sign And Send Transaction encounter failed or error?
In demo, we create a test transaction, that send some tokens in Ethereum Goerli Testnet, after you login from particle auth, other wallet or private key, your account may not have enough tokens.
you could get some test tokens from out test account, in fileTestAccount.cs
, we provide private keys for you to test in demo.
or get test tokens from the following URL
https://faucets.chain.link/ or https://goerlifaucet.com/
Before sign and send transaction, make sure you have enough token to finish the transaction.
iOS
After export to Xcode project, when you encounter error ''Module complied with Swift 5.6.1 cannot be imported by the Swift 5.7 complier'' ?
Firstly, check the Podfile, do you add the code in Edit Podfile in Prerequistites.
Secondly, check the Podfile, do you add the pods to under right target.
more pod version information is here.
https://github.com/Particle-Network/particle-ios
https://github.com/Particle-Network/particle-connect-ios
Here is an example in Podfile. All particle pods should under target 'Unity-iPhone' not target 'UnityFramework’.
2. After export to Xcode project, when you encounter error ''Cannot find type 'NativeCallsProtocol'.h in scope''.
Make sure you have changed NativaProxy.h from project to public, select this file, then in the right area, you can see a Target Membership, in iOS step-5.
3. When execute pod install in Terminal, encounter error “Unable to determine Swift version for the following pods”
Remove particle pods in podfile, then execute pod install, open Unity-iPhone.xcworkspace, select Unity-iPhone under TARGETS, in Building Settings, Swift Complier-Language, set swift version to swift 5, if there is no Swift Complier section, you should create an empty swift file, you can see swift version after do that.
\
Android
Last updated