├── .gitignore ├── .gitmodules ├── LICENSE ├── android ├── bcx │ ├── .gitignore │ ├── .idea │ │ ├── encodings.xml │ │ ├── gradle.xml │ │ ├── misc.xml │ │ ├── runConfigurations.xml │ │ └── vcs.xml │ ├── .project │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── sdkbox │ │ │ │ └── test │ │ │ │ └── bcx │ │ │ │ └── ExampleInstrumentedTest.java │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── sdkbox │ │ │ │ │ └── test │ │ │ │ │ └── bcx │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── drawable │ │ │ │ └── ic_launcher_background.xml │ │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── sdkbox │ │ │ └── test │ │ │ └── bcx │ │ │ └── ExampleUnitTest.java │ ├── bcxbridge │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── deps │ │ │ └── unityplayer.jar │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── cocos │ │ │ │ └── bcx_sdk │ │ │ │ └── unity │ │ │ │ └── bridge │ │ │ │ └── ExampleInstrumentedTest.java │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── cocos │ │ │ │ │ └── bcx_sdk │ │ │ │ │ └── unity │ │ │ │ │ └── bridge │ │ │ │ │ └── Bridge.java │ │ │ └── res │ │ │ │ └── values │ │ │ │ └── strings.xml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── cocos │ │ │ └── bcx_sdk │ │ │ └── unity │ │ │ └── bridge │ │ │ └── ExampleUnitTest.java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle └── genBridgeLibAndSync.sh ├── ios └── genBridgeLibAndSync.sh ├── readme.md ├── readme_cn.md ├── tool └── genLibAndSync.sh └── unity └── bcx ├── .gitignore ├── Assets ├── BCX.meta ├── BCX │ ├── BCX.prefab │ ├── BCX.prefab.meta │ ├── BCXAndroidReceiver.cs │ ├── BCXAndroidReceiver.cs.meta │ ├── BCXWrapper.cs │ ├── BCXWrapper.cs.meta │ ├── BCXWrapperAndroid.cs │ ├── BCXWrapperAndroid.cs.meta │ ├── BCXWrapperBase.cs │ ├── BCXWrapperBase.cs.meta │ ├── BCXWrapperDummy.cs │ ├── BCXWrapperDummy.cs.meta │ ├── BCXWrapperIOS.cs │ ├── BCXWrapperIOS.cs.meta │ ├── Document.meta │ ├── Document │ │ ├── android_export_setting.png │ │ ├── android_export_setting.png.meta │ │ ├── readme.md │ │ ├── readme.md.meta │ │ ├── versions.md │ │ ├── versions.md.meta │ │ ├── xcode_secp_target_setting.png │ │ └── xcode_secp_target_setting.png.meta │ ├── Editor.meta │ ├── Editor │ │ ├── ExtractTarGz.cs │ │ ├── ExtractTarGz.cs.meta │ │ ├── ProjectFileHook.cs │ │ ├── ProjectFileHook.cs.meta │ │ ├── Utils.cs │ │ ├── Utils.cs.meta │ │ ├── iOS.meta │ │ └── iOS │ │ │ ├── BCXUnitySDK.tar.gz │ │ │ └── BCXUnitySDK.tar.gz.meta │ ├── Plugins.meta │ ├── Plugins │ │ ├── Android.meta │ │ ├── Android │ │ │ ├── bcx_sdk.aar │ │ │ ├── bcx_sdk.aar.meta │ │ │ ├── bcxbridge.aar │ │ │ └── bcxbridge.aar.meta │ │ └── iOS.meta │ ├── Sample.meta │ ├── Sample │ │ ├── BCXTest.cs │ │ ├── BCXTest.cs.meta │ │ ├── SampleScene.unity │ │ └── SampleScene.unity.meta │ ├── UnityMainThreadDispatcher.cs │ └── UnityMainThreadDispatcher.cs.meta ├── JSON.meta ├── JSON │ ├── Editor.meta │ ├── Editor │ │ ├── JSONChecker.cs │ │ └── JSONChecker.cs.meta │ ├── JSONObject.cs │ ├── JSONObject.cs.meta │ ├── LICENSE.md │ ├── LICENSE.md.meta │ ├── VectorTemplates.cs │ ├── VectorTemplates.cs.meta │ ├── readme.txt │ └── readme.txt.meta ├── Plugins.meta └── Plugins │ ├── Android.meta │ └── Android │ ├── mainTemplate.gradle │ └── mainTemplate.gradle.meta ├── Packages └── manifest.json └── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "android/AndroidSdk"] 2 | path = android/AndroidSdk 3 | url = https://github.com/hugohuang1111/bcx-android-sdk.git 4 | [submodule "ios/iOSSDK"] 5 | path = ios/iOSSDK 6 | url = https://github.com/hugohuang1111/bcx-ios-sdk.git 7 | -------------------------------------------------------------------------------- /android/bcx/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /android/bcx/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /android/bcx/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | -------------------------------------------------------------------------------- /android/bcx/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /android/bcx/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /android/bcx/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/bcx/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | bcx 4 | Project bcx created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /android/bcx/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /android/bcx/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/bcx/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.sdkbox.test.bcx" 7 | minSdkVersion 14 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:28.0.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | implementation project(path: ':bcxbridge') 29 | } 30 | -------------------------------------------------------------------------------- /android/bcx/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /android/bcx/app/src/androidTest/java/com/sdkbox/test/bcx/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.sdkbox.test.bcx; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.sdkbox.test.bcx", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/java/com/sdkbox/test/bcx/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sdkbox.test.bcx; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import com.cocos.bcx_sdk.unity.bridge.Bridge; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | List mListNode = Arrays.asList("ws://39.106.126.54:8049", "ws://39.106.126.54:8049"); 19 | String faucetUrl = "http://47.93.62.96:8041"; 20 | String chainId = "7d89b84f22af0b150780a2b121aa6c715b19261c8b7fe0fda3a564574ed7d3e9"; 21 | String coreAsset = "COCOS"; 22 | boolean isOpenLog = true; 23 | Bridge.connect(chainId, mListNode, faucetUrl, coreAsset, isOpenLog, this); 24 | 25 | // Bridge.reflectionCall("{\"p\":[\"hugo\",\"111111\"],\"f\":\"password_login\"}"); 26 | Bridge.reflectionCall("{\"p\":[[\"string1\",\"string2\"]],\"f\":\"lookup_nh_asset\"}"); 27 | // Bridge.reflectionCall("{\"f\":\"get_version_info\"}"); 28 | // Bridge.reflectionCall("{\"f\":\"log_out\"}"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BCX 3 | 4 | -------------------------------------------------------------------------------- /android/bcx/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/bcx/app/src/test/java/com/sdkbox/test/bcx/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.sdkbox.test.bcx; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /android/bcx/bcxbridge/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /libs 3 | /deps 4 | -------------------------------------------------------------------------------- /android/bcx/bcxbridge/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | } 25 | 26 | dependencies { 27 | compileOnly files('deps/unityplayer.jar') 28 | compileOnly files('deps/bcx_sdk.aar') 29 | 30 | implementation 'com.android.support:appcompat-v7:28.0.0' 31 | testImplementation 'junit:junit:4.12' 32 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 34 | 35 | // implenment websocket 36 | implementation 'com.neovisionaries:nv-websocket-client:1.30' 37 | // implenment bitcoinj 38 | implementation 'org.bitcoinj:bitcoinj-core:0.14.7' 39 | implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' 40 | implementation group: "org.tukaani", name: "xz", version: "1.6" 41 | implementation 'com.squareup.okhttp3:okhttp:3.12.1' 42 | // spongycastle 43 | implementation 'com.madgag.spongycastle:core:1.58.0.0' 44 | implementation 'com.madgag.spongycastle:prov:1.58.0.0' 45 | implementation 'com.madgag.spongycastle:pkix:1.54.0.0' 46 | implementation 'com.madgag.spongycastle:pg:1.54.0.0' 47 | // fasterxml 48 | implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.7' 49 | 50 | } 51 | -------------------------------------------------------------------------------- /android/bcx/bcxbridge/deps/unityplayer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/bcxbridge/deps/unityplayer.jar -------------------------------------------------------------------------------- /android/bcx/bcxbridge/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /android/bcx/bcxbridge/src/androidTest/java/com/cocos/bcx_sdk/unity/bridge/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.cocos.bcx_sdk.unity.bridge; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.cocos.bcx_sdk.unity.bridge.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/bcx/bcxbridge/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /android/bcx/bcxbridge/src/main/java/com/cocos/bcx_sdk/unity/bridge/Bridge.java: -------------------------------------------------------------------------------- 1 | package com.cocos.bcx_sdk.unity.bridge; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.content.Context; 6 | import android.util.Log; 7 | 8 | import com.cocos.bcx_sdk.bcx_api.CocosBcxApiWrapper; 9 | import com.cocos.bcx_sdk.bcx_callback.IBcxCallBack; 10 | import com.cocos.bcx_sdk.bcx_entity.AccountType; 11 | import com.unity3d.player.UnityPlayer; 12 | 13 | import org.json.JSONArray; 14 | import org.json.JSONException; 15 | import org.json.JSONObject; 16 | 17 | import java.lang.reflect.Method; 18 | import java.lang.reflect.Type; 19 | import java.util.ArrayList; 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | public class Bridge { 24 | 25 | private static final String TAG = "BCXBridge"; 26 | private static final String GAME_OBJECT = "BCX"; 27 | 28 | private static String combineSuccessResult(String s) { 29 | return String.format("{\"code\":1,\"data\":\"%s\"}", s); 30 | } 31 | 32 | private static String combineErrorResult(String s) { 33 | return String.format("{\"code\":0,\"message\":\"%s\"}", s); 34 | } 35 | 36 | public static void reflectionCall(String json) { 37 | JSONObject obj = null; 38 | try { 39 | obj = new JSONObject(json); 40 | } catch (JSONException e) { 41 | Log.e(TAG, "parse json failed:" + e.toString()); 42 | return; 43 | } 44 | final String f = obj.optString("f", ""); 45 | JSONArray arr = obj.optJSONArray("p"); 46 | 47 | if (null == f || 0 == f.length()) { 48 | Log.e(TAG, "f is null"); 49 | return; 50 | } 51 | 52 | CocosBcxApiWrapper api = CocosBcxApiWrapper.getBcxInstance(); 53 | 54 | Method m = null; 55 | for(Method method : api.getClass().getMethods()) { 56 | if (f.equalsIgnoreCase(method.getName())) { 57 | m = method; 58 | 59 | Class[] paramTypes = m.getParameterTypes(); 60 | //Type[] paramTypes1 = m.getGenericParameterTypes(); 61 | Class returnType = m.getReturnType(); 62 | List params = new ArrayList(); 63 | 64 | if (String.class != returnType && void.class != returnType) { 65 | Log.e(TAG,"unknown return type:" + returnType.toString()); 66 | continue; 67 | } 68 | 69 | if (null != arr) { 70 | if (arr.length() > paramTypes.length) { 71 | Log.e(TAG, "params is not match:" + f); 72 | continue; 73 | } 74 | for (int i = 0; i < paramTypes.length; i++) { 75 | Class c = paramTypes[i]; 76 | if (String.class == c) { 77 | params.add(arr.optString(i, "")); 78 | } else if (boolean.class == c) { 79 | params.add(arr.optBoolean(i, false)); 80 | } else if (int.class == c) { 81 | params.add(arr.optInt(i, 0)); 82 | } else if (long.class == c) { 83 | params.add(arr.optLong(i, 0)); 84 | } else if (List.class == c) { 85 | JSONArray a = arr.optJSONArray(i); 86 | List l = new ArrayList(); 87 | for(int idx = 0; idx < a.length(); idx++) { 88 | l.add(a.optString(idx, "")); 89 | } 90 | params.add(l); 91 | } else if (IBcxCallBack.class == c) { 92 | params.add(new IBcxCallBack() { 93 | @Override 94 | public void onReceiveValue(String value) { 95 | UnityPlayer.UnitySendMessage(GAME_OBJECT, f, value); 96 | } 97 | }); 98 | } else { 99 | Log.e(TAG,"known params type:" + c.toString()); 100 | } 101 | } 102 | } 103 | 104 | try { 105 | Object rObj = null; 106 | if (0 == params.size()) { 107 | rObj = m.invoke(api); 108 | } else { 109 | rObj = m.invoke(api, params.toArray()); 110 | } 111 | if (null != rObj) { 112 | Class rCls = rObj.getClass(); 113 | if (rCls == void.class) { 114 | } else if (rCls == String.class) { 115 | UnityPlayer.UnitySendMessage(GAME_OBJECT, f, combineSuccessResult((String) rObj)); 116 | } else { 117 | Log.e(TAG, "unknown return type:" + rCls.toString()); 118 | } 119 | } 120 | } catch (Exception e) { 121 | Log.e(TAG, "call failed:" + f + ":" + e.toString()); 122 | } 123 | break; 124 | } 125 | } 126 | if (null == m) { 127 | Log.e(TAG, "not find method:" + f); 128 | } 129 | } 130 | 131 | // public static void connect(String chainId, List nodeUrls, String faucetUrl, String coreAsset, boolean isOpenLog, Activity activity) { 132 | // Activity act = null != activity ? activity : UnityPlayer.currentActivity; 133 | public static void connect(String chainId, String nodeUrlsString, String faucetUrl, String coreAsset, boolean isOpenLog) { 134 | Activity act = UnityPlayer.currentActivity; 135 | if (null == act) { 136 | Log.e(TAG, "UnityPlayer.currentActivity is null"); 137 | return; 138 | } 139 | Application app = act.getApplication(); 140 | if (null == app) { 141 | Log.e(TAG, "can't get current application"); 142 | return; 143 | } 144 | Context ctx = app; 145 | List nodeUrls = new ArrayList(Arrays.asList(nodeUrlsString.split(","))); 146 | 147 | CocosBcxApiWrapper.getBcxInstance().init(ctx); 148 | CocosBcxApiWrapper.getBcxInstance().connect(ctx, chainId, nodeUrls, faucetUrl, coreAsset, isOpenLog, 149 | new IBcxCallBack() { 150 | @Override 151 | public void onReceiveValue(String value) { 152 | UnityPlayer.UnitySendMessage(GAME_OBJECT, "connect", value); 153 | } 154 | }); 155 | Log.i(TAG, "BCX Android SDK Version:" + CocosBcxApiWrapper.getBcxInstance().get_version_info()); 156 | 157 | //String ts = "{\"code\":1,\"data\":{\"active\":{\"account_auths\":{},\"address_auths\":[],\"key_auths\":{\"COCOS5DxDPk56rAMrABeY482UySTAAABGn4EGUyzZDCyQP9VqsRyG6X\":1},\"weight_threshold\":1},\"id\":\"1.2.72961\",\"lifetime_referrer\":\"1.2.15\",\"lifetime_referrer_fee_percentage\":3000,\"membership_expiration_date\":\"1970-01-01T00:00:00\",\"name\":\"hugoo\",\"network_fee_percentage\":2000,\"options\":{\"extensions\":[],\"memo_key\":\"COCOS5DxDPk56rAMrABeY482UySTAAABGn4EGUyzZDCyQP9VqsRyG6X\",\"num_committee\":0,\"num_witness\":0,\"votes\":[],\"voting_account\":\"1.2.2\"},\"owner\":{\"account_auths\":{},\"address_auths\":[],\"key_auths\":{\"COCOS8LG2K2Pw9b44bYYj5DBuqsNKNWC9URDSwodMmHpoACcQHqQW8X\":1},\"weight_threshold\":1},\"referrer\":\"1.2.15\",\"referrer_rewards_percentage\":5000,\"registrar\":\"1.2.15\",\"statistics\":\"2.6.72961\"},\"message\":\"success\"}"; 158 | } 159 | 160 | public static void create_account(String strAccountName, String strPassword, String strAccountType, boolean isAutoLogin) { 161 | CocosBcxApiWrapper.getBcxInstance().create_account(strAccountName, strPassword, str2AccountType(strAccountType), isAutoLogin, new IBcxCallBack() { 162 | @Override 163 | public void onReceiveValue(String s) { 164 | UnityPlayer.UnitySendMessage(GAME_OBJECT, "create_account", s); 165 | } 166 | }); 167 | } 168 | 169 | private static AccountType str2AccountType(String s) { 170 | if ("WALLET".equalsIgnoreCase(s)) { 171 | return AccountType.WALLET; 172 | } 173 | return AccountType.ACCOUNT; 174 | } 175 | 176 | } 177 | -------------------------------------------------------------------------------- /android/bcx/bcxbridge/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | bcxbridge 3 | 4 | -------------------------------------------------------------------------------- /android/bcx/bcxbridge/src/test/java/com/cocos/bcx_sdk/unity/bridge/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.cocos.bcx_sdk.unity.bridge; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /android/bcx/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.4.1' 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /android/bcx/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | 20 | -------------------------------------------------------------------------------- /android/bcx/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/android/bcx/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/bcx/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Aug 21 13:23:28 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /android/bcx/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /android/bcx/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/bcx/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':bcxbridge' 2 | -------------------------------------------------------------------------------- /android/genBridgeLibAndSync.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) 4 | pushd $SHELL_FOLDER 5 | 6 | echo '' 7 | echo '>>> Generated BCX-Android-SDK' 8 | echo '' 9 | 10 | cd ./AndroidSdk/CocosBcxSdk/ 11 | ./gradlew :bcx_sdk:assembleRelease 12 | cp -v ./bcx_sdk/build/outputs/aar/bcx_sdk-release.aar ../../bcx/bcxbridge/deps/bcx_sdk.aar 13 | 14 | cd ../../bcx 15 | ./gradlew :bcxbridge:assembleRelease 16 | cp -v ./bcxbridge/build/outputs/aar/bcxbridge-release.aar ../../unity/bcx/Assets/BCX/Plugins/Android/bcxbridge.aar 17 | cp -v ./bcxbridge/deps/bcx_sdk.aar ../../unity/bcx/Assets/BCX/Plugins/Android/bcx_sdk.aar 18 | 19 | popd 20 | 21 | echo '' 22 | echo '>>> Generated BCX-Android-SDK Done' 23 | echo '' 24 | -------------------------------------------------------------------------------- /ios/genBridgeLibAndSync.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) 4 | pushd $SHELL_FOLDER 5 | 6 | echo '' 7 | echo '>>> Generated BCX-iOS-SDK' 8 | echo '' 9 | 10 | cp -r iOSSDK BCXUnitySDK 11 | 12 | cd BCXUnitySDK 13 | git clean -dxf 14 | git checkout -f 15 | rm -rf ./Example 16 | rm -rf ./.git 17 | cd .. 18 | tar -czvf BCXUnitySDK.tar.gz BCXUnitySDK 19 | rm -rf ./BCXUnitySDK 20 | 21 | mv -v ./BCXUnitySDK.tar.gz ../unity/bcx/Assets/BCX/Editor/iOS/ 22 | 23 | popd 24 | 25 | echo '' 26 | echo '>>> Generated BCX-iOS-SDK Done' 27 | echo '' 28 | 29 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | [中文](https://github.com/Cocos-BCX/UnitySDK/blob/master/readme_cn.md) 2 | 3 | # BCX-Unity-SDK 4 | 5 | 6 | ## Introduction 7 | 8 | The BCX-Unity-SDK is based on [BCX-Android-SDK](https://github.com/Cocos-BCX/AndroidSdk) and [BCX-iOS-SDK](https://github.com/Cocos-BCX/iOSSDK) , which provide a series of interfaces for Unity to operate the BCX blockchain, allowing users to handle logins, transfers, trading assets, calling contracts, and more. 9 | 10 | ## Project Description 11 | 12 | ### Directory Introduction 13 | 14 | * `android` a wrapper library of BCX-Android-SDK, so can easily call from Unity 15 | * `ios` a wrapper library of BCX-iOS-SDK, so can easily call from Unity 16 | * `unity` BCX-Unity-SDK Project, BCX-Unity-SDK is export from this project 17 | 18 | ### Script Introduction 19 | 20 | `tool/genLibAndSync.sh` Generate Android/iOS library and sync them to the BCX-Unity-SDK project. 21 | 22 | ## BCX-Unity-SDK 23 | 24 | ## Environment 25 | 26 | ### Android 27 | 28 | 1. [Android Studio](https://developer.android.com/studio) 29 | 30 | ### iOS 31 | 32 | 1. [CocoaPods](https://cocoapods.org/) 33 | 2. Xcode 34 | 35 | ### Unity 36 | 37 | 1. [Untiy 2018.1+](https://unity.com/) 38 | 2. git 39 | 40 | ## Android/iOS Library 41 | 42 | Run the following command to automatically generate the library file of the corresponding platform. 43 | 44 | ```bash 45 | ./tool/genLibAndSync.sh 46 | ``` 47 | 48 | ## Test 49 | 50 | ### Android 51 | 52 | 1. clone bcx-unity (If you're already clone, ignore this step) 53 | 54 | ```bash 55 | git clone https://github.com/Cocos-BCX/UnitySDK.git 56 | ``` 57 | 58 | 2. update submodule under repo root path 59 | 60 | ```bash 61 | git submodule update --init 62 | ``` 63 | 64 | 3. generate library (If you didn't modify the android/ios library, you can ignore this step without rebuilding) 65 | 66 | ```bash 67 | tool/genLibAndSync.sh 68 | ``` 69 | 70 | 4. Export Android project in Unity, with follow settings: 71 | 72 | ![](./unity/bcx/Assets/BCX/Document/android_export_setting.png) 73 | 74 | 5. Open the exported project with Android Studio 75 | 6. Compile, Run 76 | 77 | __NOTE1__: When compiling on Android, you may got a similar error in `Error: Cannot fit requested classes in a single dex file (# methods: 149346 > 65536). This is because Android has a limit on the number of methods in a single jar. 78 | 79 | you can fix it with the solution below: 80 | 81 | build.gradle 82 | ```gradle 83 | ... 84 | dependencies { 85 | ... 86 | 87 | implementation 'com.android.support:multidex:1.0.3' //add 88 | } 89 | ... 90 | android { 91 | 92 | defaultConfig { 93 | ... 94 | 95 | multiDexEnabled true //add 96 | } 97 | } 98 | ... 99 | ``` 100 | 101 | ref url: https://stackoverflow.com/questions/48249633/errorcannot-fit-requested-classes-in-a-single-dex-file-try-supplying-a-main-dex . 102 | 103 | __NOTE2__: if your application is target Android 9 (API level 28) or higher, you might got "RPC Connect failed", when connect to BCX blockchain. one possible reason is "CLEARTEXT communication is not permitted". you can modify AndroidManifest.xml like below: 104 | 105 | AndroidManifest.xml : 106 | ```xml 107 | 108 | 109 | 113 | ... 114 | 115 | 116 | ``` 117 | 118 | ref url: https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted 119 | 120 | 121 | ### iOS 122 | 123 | 1. clone bcx-unity (If you're already clone, ignore this step) 124 | 125 | ```bash 126 | git clone https://github.com/Cocos-BCX/UnitySDK.git 127 | ``` 128 | 129 | 2. update submodule under repo root path 130 | 131 | ```bash 132 | git submodule update --init 133 | ``` 134 | 135 | 3. generate library (If you didn't modify the android/ios library, you can ignore this step without rebuilding) 136 | 137 | ```bash 138 | tool/genLibAndSync.sh 139 | ``` 140 | 141 | 4. Export iOS project in Unity 142 | 5. run `pod install` under the exported iOS project. (if you don't have `CocoaPods` installed, install it first) 143 | 6. open `Unity-iPhone.xcworkspace` with Xcode 144 | 7. Modify the configuration of `Secp256k1_A` as shown in the figure: 145 | 146 | ![](./unity/bcx/Assets/BCX/Document/xcode_secp_target_setting.png) 147 | 148 | 8. Compile, Run 149 | 150 | 151 | ## Hint: 152 | 153 | 1. Many interfaces in BCX-iOS-SDK only receive id. id and name are both accepted in BCX-Android-SDK, so it is recommended to use id as much as possible. for example: 154 | 155 | ```C# 156 | public static void calculate_invoking_contract_fee(string strAccount, string feeAssetSymbol, string contractId, string functionName, string param) 157 | ``` 158 | 159 | you can pass "COCOS" or "1.3.0" to feeAssetSymbol parameter in Android. 160 | But in iOS, only "1.3.0" can be passed. 161 | 162 | 163 | ## API 164 | 165 | >> 166 | ```C# 167 | public static void connect(string chainId, string nodeUrl, string faucetUrl, string coreAsset, bool isOpenLog) 168 | ``` 169 | 170 | >>accountType: "ACCOUNT", "WALLET" 171 | ```C# 172 | public static void create_account(string strAccountName, string strPassword, string accountType, bool isAutoLogin) 173 | ``` 174 | 175 | >> 176 | ```C# 177 | public static void get_dao_account_objects() 178 | ``` 179 | 180 | >> 181 | ```C# 182 | public static void get_accounts(string accountId) 183 | ``` 184 | 185 | >> 186 | ```C# 187 | public static void get_full_accounts(string names_or_id, bool subscribe) 188 | ``` 189 | 190 | >> 191 | ```C# 192 | public static void lookup_nh_asset(List nh_asset_ids_or_hash) 193 | ``` 194 | 195 | >> 196 | ```C# 197 | public static void list_account_nh_asset(string account_id_or_name, List world_view_name_or_ids, int page, int pageSize) 198 | ``` 199 | 200 | >> 201 | ```C# 202 | public static void list_account_nh_asset_order(string account_id_or_name, int pageSize, int page) 203 | ``` 204 | 205 | >> 206 | ```C# 207 | public static void list_nh_asset_order(string asset_id_or_symbol, string world_view_name_or_ids, string baseDescribe, int pageSize, int page) 208 | ``` 209 | 210 | >> 211 | ```C# 212 | public static void lookup_world_view(List world_view_names) 213 | ``` 214 | 215 | >> 216 | ```C# 217 | public static void list_nh_asset_by_creator(string account_id, string worldView, int page, int pageSize) 218 | ``` 219 | 220 | >> 221 | ```C# 222 | public static void transfer_nh_asset(string password, string account_from, string account_to, string nh_asset_ids) 223 | ``` 224 | 225 | >> 226 | ```C# 227 | public static void delete_nh_asset(string fee_paying_account, string password, string nhasset_ids) 228 | ``` 229 | 230 | >> 231 | ```C# 232 | public static void cancel_nh_asset_order(string fee_paying_account, string password, string order_id) 233 | ``` 234 | 235 | >> 236 | ```C# 237 | public static void buy_nh_asset(string fee_paying_account, string password, string order_Id) 238 | ``` 239 | 240 | >> 241 | ```C# 242 | public static void create_nh_asset_order(string otcaccount, string seller, string password, string pending_order_nh_asset, string pending_order_fee, string pending_order_fee_symbol, string pending_order_memo, string pending_order_price, string pending_order_price_symbol, long pending_order_valid_time_second) 243 | ``` 244 | 245 | >> 246 | ```C# 247 | public static void upgrade_to_lifetime_member(string upgrade_account_id_or_symbol, string upgrade_account_password) 248 | ``` 249 | 250 | >> 251 | ```C# 252 | public static void get_contract(string contractNameOrId) 253 | ``` 254 | 255 | >> 256 | ```C# 257 | public static void password_login(string strAccountName, string strPassword) 258 | ``` 259 | 260 | >> 261 | ```C# 262 | public static void import_keystore(string keystore, string password, string accountType) 263 | ``` 264 | 265 | >> 266 | ```C# 267 | public static void export_keystore(string accountName, string password) 268 | ``` 269 | 270 | >> 271 | ```C# 272 | public static void import_wif_key(string wifKey, string password, string accountType) 273 | ``` 274 | 275 | >> 276 | ```C# 277 | public static void export_private_key(string accountName, string password) 278 | ``` 279 | 280 | >> 281 | ```C# 282 | public static void lookup_asset_symbols(string assetsSymbolOrId) 283 | ``` 284 | 285 | >> 286 | ```C# 287 | public static void invoking_contract(string strAccount, string password, string contractNameOrId, string functionName, string param) 288 | ``` 289 | 290 | >> 291 | ```C# 292 | public static void transfer(string password, string strFrom, string strTo, string strAmount, string strAssetSymbol, string strMemo) 293 | ``` 294 | 295 | >> 296 | ```C# 297 | public static void get_block(string nBlockNumber) 298 | ``` 299 | 300 | >> 301 | ```C# 302 | public static void get_account_history(string accountName, int nLimit) 303 | ``` 304 | 305 | >> 306 | ```C# 307 | public static void get_account_balances(string accountId, string assetsId) 308 | ``` 309 | 310 | >> 311 | ```C# 312 | public static void get_block_header(double nBlockNumber) 313 | ``` 314 | 315 | >> 316 | ```C# 317 | public static void get_dynamic_global_properties() 318 | ``` 319 | 320 | >> 321 | ```C# 322 | public static void get_transaction_in_block_info(string tr_id) 323 | ``` 324 | 325 | >> 326 | ```C# 327 | public static void get_transaction_by_id(string tr_id) 328 | ``` 329 | 330 | >> 331 | ```C# 332 | public static void decrypt_memo_message(string accountName, string password, string mMemoJson) 333 | ``` 334 | 335 | >>Get the version of BCX-Unity-SDK 336 | 337 | >>The version structure is {BCX-Unity-SDK-Version}-{BCX-iOS-SDK-Version/BCX-Android-SDK-Version} 338 | ```C# 339 | public static void get_version_info() 340 | ``` 341 | 342 | >> 343 | ```C# 344 | public static void log_out(string accountName) 345 | ``` 346 | 347 | >> 348 | ```C# 349 | public static void get_estimation_gas(string amount) 350 | ``` 351 | 352 | >> 353 | ```C# 354 | public static void update_collateral_for_gas(string mortgagor, string password, string beneficiary, string amount) 355 | ``` 356 | 357 | >> 358 | ```C# 359 | public static void get_vesting_balances(string accountNameOrId) 360 | ``` 361 | 362 | >> 363 | ```C# 364 | public static void receive_vesting_balances(string accountNameOrId, string password, string awardId) 365 | ``` 366 | 367 | >> 368 | ```C# 369 | public static void get_committee_members(string support_account) 370 | ``` 371 | 372 | >> 373 | ```C# 374 | public static void get_witnesses_members(string support_account) 375 | ``` 376 | 377 | >> type: 1 -> witnesses, 0 -> committee 378 | ```C# 379 | public static void vote_members(string vote_account, string password, int type, List vote_ids, string vote_count) 380 | ``` 381 | -------------------------------------------------------------------------------- /readme_cn.md: -------------------------------------------------------------------------------- 1 | [English](https://github.com/Cocos-BCX/UnitySDK/blob/master/readme.md) 2 | 3 | # BCX-Unity-SDK 4 | 5 | 6 | ## 介绍 7 | 8 | BCX-Unity-SDK 的实现基于 [BCX-Android-SDK](https://github.com/Cocos-BCX/AndroidSdk) 和 [BCX-iOS-SDK](https://github.com/Cocos-BCX/iOSSDK) , 它针对 Unity 封装了一系列操作 BCX 区块链的接口, 让用户处理登录, 转帐, 交易资产, 调用合约等事宜. 9 | 10 | ## 工程简介 11 | 12 | ### 目录简介 13 | 14 | * `android` 对 BCX-Android-SDK 作封装, 方便从 Unity 调用其接口 15 | * `ios` 对 BCX-iOS-SDK 作封装, 方便从 Unity 调用其接口 16 | * `unity` BCX-Unity-SDK 工程, 需要导出 BCX-Unity-SDK 也是直接把这个工程导出 17 | 18 | ### 脚本简介 19 | 20 | `tool/genLibAndSync.sh` 为 BCX-Unity-SDK 生成 Android/iOS 侧的库文件,并同步到 BCX-Unity-SDK 工程中. 21 | 22 | ## BCX-Unity-SDK 工程 23 | 24 | 以下会介绍 BCX-Unity-SDK 的运行的前提, 如何使用等 25 | 26 | ## 环境 27 | 28 | ### Android 29 | 30 | 1. [Android Studio](https://developer.android.com/studio) 31 | 32 | ### iOS 33 | 34 | 1. [CocoaPods](https://cocoapods.org/) 35 | 2. Xcode 36 | 37 | ### Unity 38 | 39 | 1. [Untiy 2018.1+](https://unity.com/) 40 | 2. git 41 | 42 | ## Android/iOS 库文件 43 | 44 | 运行以下命令, 可以自动生成对应平台的库文件. 45 | 46 | ```bash 47 | ./tool/genLibAndSync.sh 48 | ``` 49 | 50 | ## 测试 51 | 52 | ### Android 53 | 54 | 1. clone bcx-unity (如果已经clone, 就忽略这一步) 55 | 56 | ```bash 57 | git clone https://github.com/Cocos-BCX/UnitySDK.git 58 | ``` 59 | 60 | 2. 在UnitySDK的根目录下更新它的子工程 61 | 62 | ```bash 63 | git submodule update --init 64 | ``` 65 | 66 | 3. 生成 Android/iOS 库(如果没有修改 Android/iOS 的代码的话,可以忽略这一步) 67 | 68 | ```bash 69 | tool/genLibAndSync.sh 70 | ``` 71 | 72 | 4. Unity 中导出 Android 工程, 设置如下: 73 | 74 | ![](./unity/bcx/Assets/BCX/Document/android_export_setting.png) 75 | 76 | 5. 用 Android Studio 打开导出后的工程 77 | 6. 编译, 运行 78 | 79 | __NOTE1__: 在 Android 上编译时, 你可能会遇到 `Error: Cannot fit requested classes in a single dex file (# methods: 149346 > 65536)` 类似的错误, 这是因为Android 对单个 jar 的方法数有限制. 80 | 81 | 要解决这个问题, 你可以如下修改 build.gradle 文件: 82 | 83 | ```gradle 84 | ... 85 | dependencies { 86 | ... 87 | 88 | implementation 'com.android.support:multidex:1.0.3' //add 89 | } 90 | ... 91 | android { 92 | 93 | defaultConfig { 94 | ... 95 | 96 | multiDexEnabled true //add 97 | } 98 | } 99 | ... 100 | ``` 101 | 102 | 参见URL: https://www.jianshu.com/p/95211b445154 103 | 104 | __NOTE2__: 如果你的应用的目标是 Android 9 (API level 28) 或以上, 那么你在联接到 BCX 时, 可能会遇到 "RPC Connect failed". 这时很有可能的一个原因是 "CLEARTEXT communication is not permitted". 你可以像下面这样修改 AndroidManifest.xml : 105 | 106 | AndroidManifest.xml : 107 | ```xml 108 | 109 | 110 | 114 | ... 115 | 116 | 117 | ``` 118 | 119 | 参见URL: https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted 120 | 121 | 122 | ### iOS 123 | 124 | 1. clone bcx-unity (如果已经clone, 就忽略这一步) 125 | 126 | ```bash 127 | git clone https://github.com/Cocos-BCX/UnitySDK.git 128 | ``` 129 | 130 | 2. 在UnitySDK的根目录下更新它的子工程 131 | 132 | ```bash 133 | git submodule update --init 134 | ``` 135 | 136 | 3. 生成 Android/iOS 库(如果没有修改 Android/iOS 的代码的话,可以忽略这一步) 137 | 138 | ```bash 139 | tool/genLibAndSync.sh 140 | ``` 141 | 142 | 4. Unity 中导出 iOS 工程 143 | 5. 在导出后的 iOS 工程目录下, 运行 `pod install` (如果没有安装 `CocoaPods` , 需要先安装) 144 | 6. 完成后,打开 `Unity-iPhone.xcworkspace` 145 | 7. 在 Xcode 中, 修改 `Secp256k1_A` 的配置, 如图: 146 | 147 | ![](./unity/bcx/Assets/BCX/Document/xcode_secp_target_setting.png) 148 | 149 | 8. 编译, 运行 150 | 151 | 152 | ## 提示: 153 | 154 | 1. BCX-Unity-SDK 中的接口很多只接收 id , BCX-Android-SDK 中的接口基本 id, name 都接受, 所以建议在使用中, 尽量传 id . 比如: 155 | 156 | ```C# 157 | public static void calculate_invoking_contract_fee(string strAccount, string feeAssetSymbol, string contractId, string functionName, string param) 158 | ``` 159 | 160 | feeAssetSymbol 参数在 Android 中传 "COCOS", 或 “1.3.0” 都可以 161 | 但是在 iOS 中, 只能传 "1.3.0". 162 | 163 | 164 | ## API 165 | 166 | >> 167 | ```C# 168 | public static void connect(string chainId, string nodeUrl, string faucetUrl, string coreAsset, bool isOpenLog) 169 | ``` 170 | 171 | >>accountType: "ACCOUNT", "WALLET" 172 | ```C# 173 | public static void create_account(string strAccountName, string strPassword, string accountType, bool isAutoLogin) 174 | ``` 175 | 176 | >> 177 | ```C# 178 | public static void get_dao_account_objects() 179 | ``` 180 | 181 | >> 182 | ```C# 183 | public static void get_accounts(string accountId) 184 | ``` 185 | 186 | >> 187 | ```C# 188 | public static void get_full_accounts(string names_or_id, bool subscribe) 189 | ``` 190 | 191 | >> 192 | ```C# 193 | public static void lookup_nh_asset(List nh_asset_ids_or_hash) 194 | ``` 195 | 196 | >> 197 | ```C# 198 | public static void list_account_nh_asset(string account_id_or_name, List world_view_name_or_ids, int page, int pageSize) 199 | ``` 200 | 201 | >> 202 | ```C# 203 | public static void list_account_nh_asset_order(string account_id_or_name, int pageSize, int page) 204 | ``` 205 | 206 | >> 207 | ```C# 208 | public static void list_nh_asset_order(string asset_id_or_symbol, string world_view_name_or_ids, string baseDescribe, int pageSize, int page) 209 | ``` 210 | 211 | >> 212 | ```C# 213 | public static void lookup_world_view(List world_view_names) 214 | ``` 215 | 216 | >> 217 | ```C# 218 | public static void list_nh_asset_by_creator(string account_id, string worldView, int page, int pageSize) 219 | ``` 220 | 221 | >> 222 | ```C# 223 | public static void transfer_nh_asset(string password, string account_from, string account_to, string nh_asset_ids) 224 | ``` 225 | 226 | >> 227 | ```C# 228 | public static void delete_nh_asset(string fee_paying_account, string password, string nhasset_ids) 229 | ``` 230 | 231 | >> 232 | ```C# 233 | public static void cancel_nh_asset_order(string fee_paying_account, string password, string order_id) 234 | ``` 235 | 236 | >> 237 | ```C# 238 | public static void buy_nh_asset(string fee_paying_account, string password, string order_Id) 239 | ``` 240 | 241 | >> 242 | ```C# 243 | public static void create_nh_asset_order(string otcaccount, string seller, string password, string pending_order_nh_asset, string pending_order_fee, string pending_order_fee_symbol, string pending_order_memo, string pending_order_price, string pending_order_price_symbol, long pending_order_valid_time_second) 244 | ``` 245 | 246 | >> 247 | ```C# 248 | public static void upgrade_to_lifetime_member(string upgrade_account_id_or_symbol, string upgrade_account_password) 249 | ``` 250 | 251 | >> 252 | ```C# 253 | public static void get_contract(string contractNameOrId) 254 | ``` 255 | 256 | >> 257 | ```C# 258 | public static void password_login(string strAccountName, string strPassword) 259 | ``` 260 | 261 | >> 262 | ```C# 263 | public static void import_keystore(string keystore, string password, string accountType) 264 | ``` 265 | 266 | >> 267 | ```C# 268 | public static void export_keystore(string accountName, string password) 269 | ``` 270 | 271 | >> 272 | ```C# 273 | public static void import_wif_key(string wifKey, string password, string accountType) 274 | ``` 275 | 276 | >> 277 | ```C# 278 | public static void export_private_key(string accountName, string password) 279 | ``` 280 | 281 | >> 282 | ```C# 283 | public static void lookup_asset_symbols(string assetsSymbolOrId) 284 | ``` 285 | 286 | >> 287 | ```C# 288 | public static void invoking_contract(string strAccount, string password, string contractNameOrId, string functionName, string param) 289 | ``` 290 | 291 | >> 292 | ```C# 293 | public static void transfer(string password, string strFrom, string strTo, string strAmount, string strAssetSymbol, string strMemo) 294 | ``` 295 | 296 | >> 297 | ```C# 298 | public static void get_block(string nBlockNumber) 299 | ``` 300 | 301 | >> 302 | ```C# 303 | public static void get_account_history(string accountName, int nLimit) 304 | ``` 305 | 306 | >> 307 | ```C# 308 | public static void get_account_balances(string accountId, string assetsId) 309 | ``` 310 | 311 | >> 312 | ```C# 313 | public static void get_block_header(double nBlockNumber) 314 | ``` 315 | 316 | >> 317 | ```C# 318 | public static void get_dynamic_global_properties() 319 | ``` 320 | 321 | >> 322 | ```C# 323 | public static void get_transaction_in_block_info(string tr_id) 324 | ``` 325 | 326 | >> 327 | ```C# 328 | public static void get_transaction_by_id(string tr_id) 329 | ``` 330 | 331 | >> 332 | ```C# 333 | public static void decrypt_memo_message(string accountName, string password, string mMemoJson) 334 | ``` 335 | 336 | >>取 BCX-Unity-SDK 的版本信息 337 | 338 | >>版本结构为 {BCX-Unity-SDK-Version}-{BCX-iOS-SDK-Version/BCX-Android-SDK-Version} 339 | ```C# 340 | public static void get_version_info() 341 | ``` 342 | 343 | >> 344 | ```C# 345 | public static void log_out(string accountName) 346 | ``` 347 | 348 | >> 349 | ```C# 350 | public static void get_estimation_gas(string amount) 351 | ``` 352 | 353 | >> 354 | ```C# 355 | public static void update_collateral_for_gas(string mortgagor, string password, string beneficiary, string amount) 356 | ``` 357 | 358 | >> 359 | ```C# 360 | public static void get_vesting_balances(string accountNameOrId) 361 | ``` 362 | 363 | >> 364 | ```C# 365 | public static void receive_vesting_balances(string accountNameOrId, string password, string awardId) 366 | ``` 367 | 368 | >> 369 | ```C# 370 | public static void get_committee_members(string support_account) 371 | ``` 372 | 373 | >> 374 | ```C# 375 | public static void get_witnesses_members(string support_account) 376 | ``` 377 | 378 | >> type: 1 -> witnesses, 0 -> committee 379 | ```C# 380 | public static void vote_members(string vote_account, string password, int type, List vote_ids, string vote_count) 381 | ``` 382 | 383 | 384 | -------------------------------------------------------------------------------- /tool/genLibAndSync.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | 5 | SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) 6 | pushd $SHELL_FOLDER 7 | 8 | cd ../android 9 | ./genBridgeLibAndSync.sh 10 | 11 | cd ../ios 12 | ./genBridgeLibAndSync.sh 13 | 14 | popd 15 | 16 | echo 'Done' 17 | -------------------------------------------------------------------------------- /unity/bcx/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | Exports/ 4 | Assets/AssetStoreTools/ 5 | Assets/AssetStoreTools.meta 6 | 7 | # This .gitignore file should be placed at the root of your Unity project directory 8 | # 9 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 10 | # 11 | /[Ll]ibrary/ 12 | /[Tt]emp/ 13 | /[Oo]bj/ 14 | /[Bb]uild/ 15 | /[Bb]uilds/ 16 | /[Ll]ogs/ 17 | /[Mm]emoryCaptures/ 18 | 19 | # Never ignore Asset meta data 20 | !/[Aa]ssets/**/*.meta 21 | 22 | # Uncomment this line if you wish to ignore the asset store tools plugin 23 | # /[Aa]ssets/AssetStoreTools* 24 | 25 | # Autogenerated Jetbrains Rider plugin 26 | [Aa]ssets/Plugins/Editor/JetBrains* 27 | 28 | # Visual Studio cache directory 29 | .vs/ 30 | 31 | # Gradle cache directory 32 | .gradle/ 33 | 34 | # Autogenerated VS/MD/Consulo solution and project files 35 | ExportedObj/ 36 | .consulo/ 37 | *.csproj 38 | *.unityproj 39 | *.sln 40 | *.suo 41 | *.tmp 42 | *.user 43 | *.userprefs 44 | *.pidb 45 | *.booproj 46 | *.svd 47 | *.pdb 48 | *.mdb 49 | *.opendb 50 | *.VC.db 51 | 52 | # Unity3D generated meta files 53 | *.pidb.meta 54 | *.pdb.meta 55 | *.mdb.meta 56 | 57 | # Unity3D generated file on crash reports 58 | sysinfo.txt 59 | 60 | # Builds 61 | *.apk 62 | *.unitypackage 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14cca204c0a8546c08a67ea8082a1114 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCX.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_ParentPrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1690969430944418} 13 | m_IsPrefabParent: 1 14 | --- !u!1 &1690969430944418 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_PrefabParentObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 5 20 | m_Component: 21 | - component: {fileID: 4680669679584586} 22 | - component: {fileID: 114319142930153988} 23 | m_Layer: 0 24 | m_Name: BCX 25 | m_TagString: Untagged 26 | m_Icon: {fileID: 0} 27 | m_NavMeshLayer: 0 28 | m_StaticEditorFlags: 0 29 | m_IsActive: 1 30 | --- !u!4 &4680669679584586 31 | Transform: 32 | m_ObjectHideFlags: 1 33 | m_PrefabParentObject: {fileID: 0} 34 | m_PrefabInternal: {fileID: 100100000} 35 | m_GameObject: {fileID: 1690969430944418} 36 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 37 | m_LocalPosition: {x: 0, y: 0, z: 0} 38 | m_LocalScale: {x: 1, y: 1, z: 1} 39 | m_Children: [] 40 | m_Father: {fileID: 0} 41 | m_RootOrder: 0 42 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 43 | --- !u!114 &114319142930153988 44 | MonoBehaviour: 45 | m_ObjectHideFlags: 1 46 | m_PrefabParentObject: {fileID: 0} 47 | m_PrefabInternal: {fileID: 100100000} 48 | m_GameObject: {fileID: 1690969430944418} 49 | m_Enabled: 1 50 | m_EditorHideFlags: 0 51 | m_Script: {fileID: 11500000, guid: a385548ae4a934750bb6ae97ec31368e, type: 3} 52 | m_Name: 53 | m_EditorClassIdentifier: 54 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCX.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8746546b10dbc441092d395e08d9ab92 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 100100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXAndroidReceiver.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace BCX 6 | { 7 | public class BCXAndroidReceiver : MonoBehaviour { 8 | 9 | #if UNITY_ANDROID 10 | 11 | public void connect(string json) 12 | { 13 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 14 | } 15 | 16 | public void create_password_account(string json) 17 | { 18 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 19 | } 20 | 21 | public void create_wallet_account(string json) 22 | { 23 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 24 | } 25 | 26 | public void create_account(string json) 27 | { 28 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 29 | } 30 | 31 | public void get_dao_account_objects(string json) 32 | { 33 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 34 | } 35 | 36 | public void get_accounts(string json) 37 | { 38 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 39 | } 40 | 41 | public void lookup_account_names(string json) 42 | { 43 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 44 | } 45 | 46 | public void get_account_object(string json) 47 | { 48 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 49 | } 50 | 51 | public void get_account_id_by_name(string json) 52 | { 53 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 54 | } 55 | 56 | public void get_account_name_by_id(string json) 57 | { 58 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 59 | } 60 | 61 | public void get_full_accounts(string json) 62 | { 63 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 64 | } 65 | 66 | public void lookup_nh_asset(string json) 67 | { 68 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 69 | } 70 | 71 | public void list_account_nh_asset(string json) 72 | { 73 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 74 | } 75 | 76 | public void list_account_nh_asset_order(string json) 77 | { 78 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 79 | } 80 | 81 | public void list_nh_asset_order(string json) 82 | { 83 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 84 | } 85 | 86 | public void lookup_world_view(string json) 87 | { 88 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 89 | } 90 | 91 | public void get_nh_creator(string json) 92 | { 93 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 94 | } 95 | 96 | public void list_nh_asset_by_creator(string json) 97 | { 98 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 99 | } 100 | 101 | public void transfer_nh_asset(string json) 102 | { 103 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 104 | } 105 | 106 | public void delete_nh_asset(string json) 107 | { 108 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 109 | } 110 | 111 | public void cancel_nh_asset_order(string json) 112 | { 113 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 114 | } 115 | 116 | public void buy_nh_asset(string json) 117 | { 118 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 119 | } 120 | 121 | public void create_nh_asset_order(string json) 122 | { 123 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 124 | } 125 | 126 | public void upgrade_to_lifetime_member(string json) 127 | { 128 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 129 | } 130 | 131 | public void create_child_account(string json) 132 | { 133 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 134 | } 135 | 136 | public void get_objects(string json) 137 | { 138 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 139 | } 140 | 141 | public void get_contract(string json) 142 | { 143 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 144 | } 145 | 146 | public void delete_account_by_name(string json) 147 | { 148 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 149 | } 150 | 151 | public void delete_account_by_id(string json) 152 | { 153 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 154 | } 155 | 156 | public void password_login(string json) 157 | { 158 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 159 | } 160 | 161 | public void import_keystore(string json) 162 | { 163 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 164 | } 165 | 166 | public void export_keystore(string json) 167 | { 168 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 169 | } 170 | 171 | public void import_wif_key(string json) 172 | { 173 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 174 | } 175 | 176 | public void export_private_key(string json) 177 | { 178 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 179 | } 180 | 181 | public void lookup_asset_symbols(string json) 182 | { 183 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 184 | } 185 | 186 | private void get_invoking_contract_tx_id(string json) 187 | { 188 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 189 | } 190 | 191 | public void invoking_contract(string json) 192 | { 193 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 194 | } 195 | 196 | public void transfer(string json) 197 | { 198 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 199 | } 200 | 201 | public void get_block(string json) 202 | { 203 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 204 | } 205 | 206 | public void get_account_history(string json) 207 | { 208 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 209 | } 210 | 211 | public void get_all_account_balances(string json) 212 | { 213 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 214 | } 215 | 216 | public void get_account_balances(string json) 217 | { 218 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 219 | } 220 | 221 | public void get_block_header(string json) 222 | { 223 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 224 | } 225 | 226 | public void get_global_properties(string json) 227 | { 228 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 229 | } 230 | 231 | public void get_dynamic_global_properties(string json) 232 | { 233 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 234 | } 235 | 236 | public void get_transaction_in_block_info(string json) 237 | { 238 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 239 | } 240 | 241 | public void get_transaction_by_id(string json) 242 | { 243 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 244 | } 245 | 246 | public void decrypt_memo_message(string json) 247 | { 248 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 249 | } 250 | 251 | public void get_payment_qrcode_json(string json) 252 | { 253 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 254 | } 255 | 256 | public void get_estimation_gas(string json) 257 | { 258 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 259 | } 260 | 261 | public void update_collateral_for_gas(string json) 262 | { 263 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 264 | } 265 | 266 | public void get_vesting_balances(string json) 267 | { 268 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 269 | } 270 | 271 | public void receive_vesting_balances(string json) 272 | { 273 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 274 | } 275 | 276 | public void get_committee_members(string json) 277 | { 278 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 279 | } 280 | 281 | public void get_witnesses_members(string json) 282 | { 283 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 284 | } 285 | 286 | public void vote_members(string json) 287 | { 288 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 289 | } 290 | 291 | public void get_version_info(string json) 292 | { 293 | JSONObject jObj = new JSONObject(json); 294 | JSONObject codeObj = jObj.GetField("code"); 295 | JSONObject dataObj = jObj.GetField("data"); 296 | if (1 == codeObj.n) { 297 | dataObj.str = BCXWrapperBase.VERSION + "-" + dataObj.str; 298 | } 299 | jObj.SetField("data", dataObj); 300 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, jObj.ToString()); 301 | } 302 | 303 | public void log_out(string json) 304 | { 305 | BCX.BCXWrapperAndroid.notify_bcx_event(System.Reflection.MethodBase.GetCurrentMethod().Name, json); 306 | } 307 | 308 | #endif 309 | 310 | } 311 | 312 | } 313 | 314 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXAndroidReceiver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a385548ae4a934750bb6ae97ec31368e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BCX 5 | { 6 | #if UNITY_ANDROID 7 | public class BCXWrapper : BCXWrapperAndroid 8 | #elif UNITY_IOS 9 | public class BCXWrapper : BCXWrapperIOS 10 | #else 11 | public class BCXWrapper : BCXWrapperDummy 12 | #endif 13 | { 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 165f92e22ba264826b3befa6ef512c6a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperAndroid.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_ANDROID 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using UnityEngine; 8 | using AOT; 9 | 10 | namespace BCX 11 | { 12 | 13 | public class BCXWrapperAndroid : BCXWrapperBase 14 | { 15 | public static event BCXEventHandler BCXEvent; 16 | private static String WRAPPER_CLASS = "com.cocos.bcx_sdk.unity.bridge.Bridge"; 17 | 18 | public static void connect(string chainId, string nodeUrl, string faucetUrl, string coreAsset, bool isOpenLog) 19 | { 20 | #if !UNITY_EDITOR 21 | using (AndroidJavaClass jc = new AndroidJavaClass(WRAPPER_CLASS)) 22 | { 23 | jc.CallStatic("connect", chainId, String.Format("{0},{0}", nodeUrl), faucetUrl, coreAsset, isOpenLog); 24 | } 25 | #endif 26 | } 27 | 28 | /* 29 | * accountType: "ACCOUNT", "WALLET" 30 | */ 31 | public static void create_account(string strAccountName, string strPassword, string accountType, bool isAutoLogin) 32 | { 33 | #if !UNITY_EDITOR 34 | using (AndroidJavaClass jc = new AndroidJavaClass(WRAPPER_CLASS)) 35 | { 36 | jc.CallStatic("create_account", strAccountName, strPassword, accountType, isAutoLogin); 37 | } 38 | #endif 39 | } 40 | 41 | public static void get_dao_account_objects() 42 | { 43 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name); 44 | } 45 | 46 | public static void get_accounts(string accountId) 47 | { 48 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountId); 49 | } 50 | 51 | public static void get_full_accounts(string names_or_id, bool subscribe) 52 | { 53 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, names_or_id, subscribe); 54 | } 55 | 56 | public static void lookup_nh_asset(List nh_asset_ids_or_hash) 57 | { 58 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, nh_asset_ids_or_hash); 59 | } 60 | 61 | public static void list_account_nh_asset(string account_id_or_name, List world_view_name_or_ids, int page, int pageSize) 62 | { 63 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, account_id_or_name, world_view_name_or_ids, page, pageSize); 64 | } 65 | 66 | public static void list_account_nh_asset_order(string account_id_or_name, int pageSize, int page) 67 | { 68 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, account_id_or_name, pageSize, page); 69 | } 70 | 71 | public static void list_nh_asset_order(string asset_id_or_symbol, string world_view_name_or_ids, string baseDescribe, int pageSize, int page) 72 | { 73 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, asset_id_or_symbol, world_view_name_or_ids, baseDescribe, pageSize, page); 74 | } 75 | 76 | public static void lookup_world_view(List world_view_names) 77 | { 78 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, world_view_names); 79 | } 80 | 81 | public static void list_nh_asset_by_creator(string account_id, string worldView, int page, int pageSize) 82 | { 83 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, account_id, worldView, page, pageSize); 84 | } 85 | 86 | public static void transfer_nh_asset(string password, string account_from, string account_to, string nh_asset_ids) 87 | { 88 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, password, account_from, account_to, str2list(nh_asset_ids)); 89 | } 90 | 91 | public static void delete_nh_asset(string fee_paying_account, string password, string nhasset_ids) 92 | { 93 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, fee_paying_account, password, str2list(nhasset_ids)); 94 | } 95 | 96 | public static void cancel_nh_asset_order(string fee_paying_account, string password, string order_id) 97 | { 98 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, fee_paying_account, password, order_id); 99 | } 100 | 101 | public static void buy_nh_asset(string fee_paying_account, string password, string order_Id) 102 | { 103 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, fee_paying_account, password, order_Id); 104 | } 105 | 106 | public static void create_nh_asset_order(string otcaccount, string seller, string password, string pending_order_nh_asset, string pending_order_fee, string pending_order_fee_symbol, string pending_order_memo, string pending_order_price, string pending_order_price_symbol, long pending_order_valid_time_second) 107 | { 108 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, otcaccount, seller, password, pending_order_nh_asset, pending_order_fee, pending_order_fee_symbol, pending_order_memo, pending_order_price, pending_order_price_symbol, pending_order_valid_time_second * 1000); 109 | } 110 | 111 | public static void upgrade_to_lifetime_member(string upgrade_account_id_or_symbol, string upgrade_account_password) 112 | { 113 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, upgrade_account_id_or_symbol, upgrade_account_password); 114 | } 115 | 116 | public static void get_contract(string contractNameOrId) 117 | { 118 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, contractNameOrId); 119 | } 120 | 121 | public static void password_login(string strAccountName, string strPassword) 122 | { 123 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, strAccountName, strPassword); 124 | } 125 | 126 | public static void import_keystore(string keystore, string password, string accountType) 127 | { 128 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, keystore, password, accountType); 129 | } 130 | 131 | public static void export_keystore(string accountName, string password) 132 | { 133 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountName, password); 134 | } 135 | 136 | public static void import_wif_key(string wifKey, string password, string accountType) 137 | { 138 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, wifKey, password, accountType); 139 | } 140 | 141 | public static void export_private_key(string accountName, string password) 142 | { 143 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountName, password); 144 | } 145 | 146 | public static void lookup_asset_symbols(string assetsSymbolOrId) 147 | { 148 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, assetsSymbolOrId); 149 | } 150 | 151 | public static void invoking_contract(string strAccount, string password, string contractNameOrId, string functionName, string param) 152 | { 153 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, strAccount, password, contractNameOrId, functionName, param); 154 | } 155 | 156 | public static void transfer(string password, string strFrom, string strTo, string strAmount, string strAssetSymbol, string strMemo) 157 | { 158 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, password, strFrom, strTo, strAmount, strAssetSymbol, strMemo); 159 | } 160 | 161 | public static void get_block(string nBlockNumber) 162 | { 163 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, nBlockNumber); 164 | } 165 | 166 | public static void get_account_history(string accountName, int nLimit) 167 | { 168 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountName, nLimit); 169 | } 170 | 171 | public static void get_account_balances(string accountId, string assetsId) 172 | { 173 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountId, assetsId); 174 | } 175 | 176 | public static void get_block_header(double nBlockNumber) 177 | { 178 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, nBlockNumber); 179 | } 180 | 181 | public static void get_dynamic_global_properties() 182 | { 183 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name); 184 | } 185 | 186 | public static void get_transaction_in_block_info(string tr_id) 187 | { 188 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, tr_id); 189 | } 190 | 191 | public static void get_transaction_by_id(string tr_id) 192 | { 193 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, tr_id); 194 | } 195 | 196 | public static void decrypt_memo_message(string accountName, string password, string mMemoJson) 197 | { 198 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountName, password, mMemoJson); 199 | } 200 | 201 | public static void get_version_info() 202 | { 203 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name); 204 | } 205 | 206 | public static void log_out(string accountName) 207 | { 208 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name); 209 | } 210 | 211 | public static void get_estimation_gas(string amount) 212 | { 213 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, amount); 214 | } 215 | 216 | public static void update_collateral_for_gas(string mortgagor, string password, string beneficiary, string amount) 217 | { 218 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, mortgagor, password, beneficiary, amount); 219 | } 220 | 221 | public static void get_vesting_balances(string accountNameOrId) 222 | { 223 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountNameOrId); 224 | } 225 | 226 | public static void receive_vesting_balances(string accountNameOrId, string password, string awardId) 227 | { 228 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, accountNameOrId, password, awardId); 229 | } 230 | 231 | public static void get_committee_members(string support_account) 232 | { 233 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, support_account); 234 | } 235 | 236 | public static void get_witnesses_members(string support_account) 237 | { 238 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, support_account); 239 | } 240 | 241 | /* 242 | * @Param type: 1 -> witnesses, 0 -> committee 243 | * 244 | */ 245 | public static void vote_members(string vote_account, string password, int type, List vote_ids, string vote_count) 246 | { 247 | string stype = ""; 248 | if (0 == type) 249 | { 250 | stype = "committee"; 251 | } 252 | else if (1 == type) 253 | { 254 | stype = "witnesses"; 255 | } 256 | else 257 | { 258 | Debug.Log("Invalid param type"); 259 | } 260 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, vote_account, password, stype, vote_ids, vote_count); 261 | } 262 | 263 | 264 | 265 | public static void notify_bcx_event(string evt, string json) 266 | { 267 | BCXWrapperAndroid.BCXEvent.Invoke(evt, json); 268 | } 269 | 270 | private static JSONObject params2JSON(params object[] objs) 271 | { 272 | JSONObject objP = new JSONObject(JSONObject.Type.ARRAY); 273 | foreach (var item in objs) 274 | { 275 | string s = item as string; 276 | if (null != s) 277 | { 278 | objP.Add(s); 279 | } 280 | else if (IsNumber(item)) 281 | { 282 | objP.Add(Convert.ToInt32(item)); 283 | } 284 | else if (item is bool) 285 | { 286 | objP.Add(Convert.ToInt32((bool)item)); 287 | } 288 | else if (item is List) 289 | { 290 | JSONObject objL = new JSONObject(JSONObject.Type.ARRAY); 291 | foreach(var o in (item as List)) 292 | { 293 | objL.Add(o); 294 | } 295 | objP.Add(objL); 296 | } 297 | } 298 | return objP; 299 | } 300 | 301 | private static void Invoke(string f, params object[] arr) 302 | { 303 | JSONObject obj = new JSONObject(JSONObject.Type.OBJECT); 304 | obj.AddField("f", f); 305 | obj.AddField("p", params2JSON(arr)); 306 | 307 | #if !UNITY_EDITOR 308 | using (AndroidJavaClass jc = new AndroidJavaClass(WRAPPER_CLASS)) 309 | { 310 | jc.CallStatic("reflectionCall", obj.ToString()); 311 | } 312 | #endif 313 | } 314 | 315 | } 316 | } 317 | 318 | #endif 319 | 320 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperAndroid.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f81d05f2ccbdb487f81f6b78eee32324 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace BCX 7 | { 8 | public class BCXWrapperBase 9 | { 10 | public static string VERSION = "1.0.0"; 11 | public delegate void BCXEventHandler(string evt, string json); 12 | 13 | protected static List str2list(string str) 14 | { 15 | return str.Split(',').Select(p => p.Trim()).ToList(); 16 | } 17 | 18 | protected static bool IsNumber(object value) 19 | { 20 | return value is sbyte 21 | || value is byte 22 | || value is short 23 | || value is ushort 24 | || value is int 25 | || value is uint 26 | || value is long 27 | || value is ulong 28 | || value is float 29 | || value is double 30 | || value is decimal; 31 | } 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff1ed75fc39d740b49fb1bf5d074e27b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperDummy.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | namespace BCX 7 | { 8 | 9 | public class BCXWrapperDummy : BCXWrapperBase 10 | { 11 | public static event BCXEventHandler BCXEvent; 12 | private static String DUMMY_NOTE = "Dummy on current platform"; 13 | 14 | public static void connect(string chainId, string nodeUrlString, string faucetUrl, string coreAsset, bool isOpenLog) 15 | { 16 | Debug.Log(DUMMY_NOTE); 17 | } 18 | 19 | public static void create_account(string strAccountName, string strPassword, string accountType, bool isAutoLogin) 20 | { 21 | Debug.Log(DUMMY_NOTE); 22 | } 23 | 24 | public static void get_dao_account_objects() 25 | { 26 | Debug.Log(DUMMY_NOTE); 27 | } 28 | 29 | public static void get_accounts(string accountId) 30 | { 31 | Debug.Log(DUMMY_NOTE); 32 | } 33 | 34 | public static void get_full_accounts(string names_or_id, bool subscribe) 35 | { 36 | Debug.Log(DUMMY_NOTE); 37 | } 38 | 39 | public static void lookup_nh_asset(List nh_asset_ids_or_hash) 40 | { 41 | Debug.Log(DUMMY_NOTE); 42 | } 43 | 44 | public static void list_account_nh_asset(string account_id_or_name, List world_view_name_or_ids, int page, int pageSize) 45 | { 46 | Debug.Log(DUMMY_NOTE); 47 | } 48 | 49 | public static void list_account_nh_asset_order(string account_id_or_name, int pageSize, int page) 50 | { 51 | Debug.Log(DUMMY_NOTE); 52 | } 53 | 54 | public static void list_nh_asset_order(string asset_id_or_symbol, string world_view_name_or_ids, string baseDescribe, int pageSize, int page) 55 | { 56 | Debug.Log(DUMMY_NOTE); 57 | } 58 | 59 | public static void lookup_world_view(List world_view_names) 60 | { 61 | Debug.Log(DUMMY_NOTE); 62 | } 63 | 64 | public static void list_nh_asset_by_creator(string account_id, string worldView, int page, int pageSize) 65 | { 66 | Debug.Log(DUMMY_NOTE); 67 | } 68 | 69 | public static void transfer_nh_asset(string password, string account_from, string account_to, string nh_asset_ids) 70 | { 71 | Debug.Log(DUMMY_NOTE); 72 | } 73 | 74 | public static void delete_nh_asset(string fee_paying_account, string password, string nhasset_ids) 75 | { 76 | Debug.Log(DUMMY_NOTE); 77 | } 78 | 79 | public static void cancel_nh_asset_order(string fee_paying_account, string password, string order_id) 80 | { 81 | Debug.Log(DUMMY_NOTE); 82 | } 83 | 84 | public static void buy_nh_asset(string fee_paying_account, string password, string order_Id) 85 | { 86 | Debug.Log(DUMMY_NOTE); 87 | } 88 | 89 | public static void create_nh_asset_order(string otcaccount, string seller, string password, string pending_order_nh_asset, string pending_order_fee, string pending_order_fee_symbol, string pending_order_memo, string pending_order_price, string pending_order_price_symbol, long pending_order_valid_time_second) 90 | { 91 | Debug.Log(DUMMY_NOTE); 92 | } 93 | 94 | public static void upgrade_to_lifetime_member(string upgrade_account_id_or_symbol, string upgrade_account_password) 95 | { 96 | Debug.Log(DUMMY_NOTE); 97 | } 98 | 99 | public static void get_contract(string contractNameOrId) 100 | { 101 | Debug.Log(DUMMY_NOTE); 102 | } 103 | 104 | public static void password_login(string strAccountName, string strPassword) 105 | { 106 | Debug.Log(DUMMY_NOTE); 107 | } 108 | 109 | public static void import_keystore(string keystore, string password, string accountType) 110 | { 111 | Debug.Log(DUMMY_NOTE); 112 | } 113 | 114 | public static void export_keystore(string accountName, string password) 115 | { 116 | Debug.Log(DUMMY_NOTE); 117 | } 118 | 119 | public static void import_wif_key(string wifKey, string password, string accountType) 120 | { 121 | Debug.Log(DUMMY_NOTE); 122 | } 123 | 124 | public static void export_private_key(string accountName, string password) 125 | { 126 | Debug.Log(DUMMY_NOTE); 127 | } 128 | 129 | public static void lookup_asset_symbols(string assetsSymbolOrId) 130 | { 131 | Debug.Log(DUMMY_NOTE); 132 | } 133 | 134 | public static void invoking_contract(string strAccount, string password, string contractNameOrId, string functionName, string param) 135 | { 136 | Debug.Log(DUMMY_NOTE); 137 | } 138 | 139 | public static void transfer(string password, string strFrom, string strTo, string strAmount, string strAssetSymbol, string strMemo) 140 | { 141 | Debug.Log(DUMMY_NOTE); 142 | } 143 | 144 | public static void get_block(string nBlockNumber) 145 | { 146 | Debug.Log(DUMMY_NOTE); 147 | } 148 | 149 | public static void get_account_history(string accountName, int nLimit) 150 | { 151 | Debug.Log(DUMMY_NOTE); 152 | } 153 | 154 | public static void get_account_balances(string accountId, string assetsId) 155 | { 156 | Debug.Log(DUMMY_NOTE); 157 | } 158 | 159 | public static void get_block_header(double nBlockNumber) 160 | { 161 | Debug.Log(DUMMY_NOTE); 162 | } 163 | 164 | public static void get_dynamic_global_properties() 165 | { 166 | Debug.Log(DUMMY_NOTE); 167 | } 168 | 169 | public static void get_transaction_in_block_info(string tr_id) 170 | { 171 | Debug.Log(DUMMY_NOTE); 172 | } 173 | 174 | public static void get_transaction_by_id(string tr_id) 175 | { 176 | Debug.Log(DUMMY_NOTE); 177 | } 178 | 179 | public static void decrypt_memo_message(string accountName, string password, string mMemoJson) 180 | { 181 | Debug.Log(DUMMY_NOTE); 182 | } 183 | 184 | public static void get_version_info() 185 | { 186 | Debug.Log(DUMMY_NOTE); 187 | } 188 | 189 | public static void log_out() 190 | { 191 | Debug.Log(DUMMY_NOTE); 192 | } 193 | 194 | public static void get_estimation_gas(string amount) 195 | { 196 | Debug.Log(DUMMY_NOTE); 197 | } 198 | 199 | public static void update_collateral_for_gas(string mortgagor, string password, string beneficiary, string amount) 200 | { 201 | Debug.Log(DUMMY_NOTE); 202 | } 203 | 204 | public static void get_vesting_balances(string accountNameOrId) 205 | { 206 | Debug.Log(DUMMY_NOTE); 207 | } 208 | 209 | public static void receive_vesting_balances(string accountNameOrId, string password, string awardId) 210 | { 211 | Debug.Log(DUMMY_NOTE); 212 | } 213 | 214 | public static void get_committee_members(string support_account) 215 | { 216 | Debug.Log(DUMMY_NOTE); 217 | } 218 | 219 | public static void get_witnesses_members(string support_account) 220 | { 221 | Debug.Log(DUMMY_NOTE); 222 | } 223 | 224 | public static void vote_members(string vote_account, string password, int type, List vote_ids, string vote_count) 225 | { 226 | Debug.Log(DUMMY_NOTE); 227 | } 228 | 229 | 230 | } 231 | } 232 | 233 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperDummy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5a69e2e12ff84694ba08661f336b34f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperIOS.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_IOS 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using UnityEngine; 8 | using AOT; 9 | 10 | 11 | namespace BCX 12 | { 13 | 14 | public class BCXWrapperIOS : BCXWrapperBase 15 | { 16 | public static event BCXEventHandler BCXEvent; 17 | private static Dictionary nameMap = new Dictionary(); 18 | 19 | public static void connect(string chainId, string nodeUrlString, string faucetUrl, string coreAsset, bool isOpenLog) 20 | { 21 | #if !UNITY_EDITOR 22 | BCX_set_unity_callback(BCXBridgeCallback); 23 | BCX_connect(chainId, nodeUrlString, faucetUrl, coreAsset, isOpenLog); 24 | #endif 25 | } 26 | 27 | public static void create_account(string strAccountName, string strPassword, string accountType, bool isAutoLogin) 28 | { 29 | #if !UNITY_EDITOR 30 | BCX_create_account(strAccountName, strPassword, accountType, isAutoLogin); 31 | #endif 32 | } 33 | 34 | public static void get_dao_account_objects() 35 | { 36 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_QueryAllAccountSuccess"); 37 | } 38 | 39 | public static void get_accounts(string accountId) 40 | { 41 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetAccount", accountId); 42 | } 43 | 44 | public static void get_full_accounts(string names_or_id, bool subscribe) 45 | { 46 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetFullAccount", names_or_id); 47 | } 48 | 49 | public static void lookup_nh_asset(List nh_asset_ids_or_hash) 50 | { 51 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_LookupNHAsset", nh_asset_ids_or_hash); 52 | } 53 | 54 | public static void list_account_nh_asset(string account_id_or_name, List world_view_name_or_ids, int page, int pageSize) 55 | { 56 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_ListAccountNHAsset", account_id_or_name, world_view_name_or_ids, pageSize, page); 57 | } 58 | 59 | public static void list_account_nh_asset_order(string account_id_or_name, int pageSize, int page) 60 | { 61 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_ListAccountNHAssetOrder", account_id_or_name, pageSize, page); 62 | } 63 | 64 | public static void list_nh_asset_order(string asset_id_or_symbol, string world_view_name_or_ids, string baseDescribe, int pageSize, int page) 65 | { 66 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_AllListNHAssetOrder", asset_id_or_symbol, world_view_name_or_ids, baseDescribe, pageSize, page); 67 | } 68 | 69 | public static void lookup_world_view(List world_view_names) 70 | { 71 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_LookupWorldView", world_view_names); 72 | } 73 | 74 | public static void list_nh_asset_by_creator(string account_id, string worldView, int page, int pageSize) 75 | { 76 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_ListNHAssetByCreator", account_id, pageSize, page); 77 | } 78 | 79 | public static void transfer_nh_asset(string password, string account_from, string account_to, string nh_asset_id) 80 | { 81 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_TransferNHAsset", account_from, account_to, nh_asset_id, password); 82 | } 83 | 84 | public static void delete_nh_asset(string fee_paying_account, string password, string nhasset_id) 85 | { 86 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_DeleteNHAssetAccount", fee_paying_account, password, nhasset_id); 87 | } 88 | 89 | public static void cancel_nh_asset_order(string fee_paying_account, string password, string order_id) 90 | { 91 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_CancelNHAssetAccount", fee_paying_account, password, order_id); 92 | } 93 | 94 | public static void buy_nh_asset(string fee_paying_account, string password, string order_Id) 95 | { 96 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_BuyNHAssetOrderID", order_Id, fee_paying_account, password); 97 | } 98 | 99 | public static void create_nh_asset_order(string otcaccount, string seller, string password, string pending_order_nh_asset, string pending_order_fee, string pending_order_fee_symbol, string pending_order_memo, string pending_order_price, string pending_order_price_symbol, long pending_order_valid_time_second) 100 | { 101 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_SellNHAssetSeller", seller, password, pending_order_nh_asset, pending_order_memo, pending_order_price, pending_order_fee, pending_order_fee_symbol, pending_order_price_symbol, pending_order_valid_time_second.ToString()); 102 | } 103 | 104 | public static void upgrade_to_lifetime_member(string upgrade_account_id_or_symbol, string upgrade_account_password) 105 | { 106 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_UpgradeMemberAccount", upgrade_account_id_or_symbol, upgrade_account_password); 107 | } 108 | 109 | public static void get_contract(string contractNameOrId) 110 | { 111 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetContract", contractNameOrId); 112 | } 113 | 114 | public static void password_login(string strAccountName, string strPassword) 115 | { 116 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_LoginAccountWithName", strAccountName, strPassword); 117 | } 118 | 119 | public static void import_keystore(string keystore, string password, string accountType) 120 | { 121 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_RecoverWalletWithString", keystore, password); 122 | } 123 | 124 | public static void export_keystore(string accountName, string password) 125 | { 126 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_BackupWalletWithAccountName", accountName); 127 | } 128 | 129 | public static void import_wif_key(string wifKey, string password, string accountType) 130 | { 131 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_ImportWalletWithPrivate", wifKey, accountType, password); 132 | } 133 | 134 | public static void export_private_key(string accountName, string password) 135 | { 136 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetPrivateWithName", accountName, password); 137 | } 138 | 139 | public static void lookup_asset_symbols(string assetsSymbolOrId) 140 | { 141 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetAsset", assetsSymbolOrId); 142 | } 143 | 144 | public static void invoking_contract(string strAccount, string password, string contractNameOrId, string functionName, string param) 145 | { 146 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_CallContract", contractNameOrId, str2list(param), functionName, strAccount, password); 147 | } 148 | 149 | public static void transfer(string password, string strFrom, string strTo, string strAmount, string strAssetSymbol, string strMemo) 150 | { 151 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_TransferFromAccount", strFrom, strTo, password, strAssetSymbol, strAmount, strMemo); 152 | } 153 | 154 | public static void get_block(string nBlockNumber) 155 | { 156 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetBlockWithBlockNum", nBlockNumber); 157 | } 158 | 159 | public static void get_account_history(string accountName, int nLimit) 160 | { 161 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetAccountHistory", accountName, nLimit); 162 | } 163 | 164 | public static void get_account_balances(string accountId, string assetsId) 165 | { 166 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetAccountBalance", accountId, str2list(assetsId)); 167 | } 168 | 169 | public static void get_block_header(double nBlockNumber) 170 | { 171 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetBlockHeaderWithBlockNum", nBlockNumber); 172 | } 173 | 174 | public static void get_dynamic_global_properties() 175 | { 176 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetDynamicGlobalPropertiesWithSuccess"); 177 | } 178 | 179 | public static void get_transaction_in_block_info(string tr_id) 180 | { 181 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetTransactionBlockWithHash", tr_id); 182 | } 183 | 184 | public static void get_transaction_by_id(string tr_id) 185 | { 186 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetTransactionById", tr_id); 187 | } 188 | 189 | public static void decrypt_memo_message(string accountName, string password, string mMemoJson) 190 | { 191 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_DecryptMemo", accountName, password, mMemoJson); 192 | } 193 | 194 | public static void get_version_info() 195 | { 196 | #if !UNITY_EDITOR 197 | BCX_get_version_info(); 198 | #endif 199 | } 200 | 201 | public static void log_out(string accountName) 202 | { 203 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_DeleteWalletAccountName", accountName); 204 | } 205 | 206 | public static void get_estimation_gas(string amount) 207 | { 208 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_Gas_EstimationWithCOCOSAmout", amount); 209 | } 210 | 211 | public static void update_collateral_for_gas(string mortgagor, string password, string beneficiary, string samount) 212 | { 213 | long amount = 0; 214 | if (!string.IsNullOrEmpty(samount)) { 215 | amount = Convert.ToInt64(samount); 216 | } 217 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GasWithMortgager", mortgagor, beneficiary, amount, password); 218 | } 219 | 220 | public static void get_vesting_balances(string accountNameOrId) 221 | { 222 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_QueryVestingBalance", accountNameOrId); 223 | } 224 | 225 | public static void receive_vesting_balances(string accountNameOrId, string password, string awardId) 226 | { 227 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_ClaimVestingBalance", accountNameOrId, password, awardId); 228 | } 229 | 230 | public static void get_committee_members(string support_account) 231 | { 232 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetCommitteeMemberInfoVoteAccountId", support_account); 233 | } 234 | 235 | public static void get_witnesses_members(string support_account) 236 | { 237 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_GetWitnessInfoVoteAccountId", support_account); 238 | } 239 | 240 | /* 241 | * @Param type: 1 -> witnesses, 0 -> committee 242 | * 243 | */ 244 | public static void vote_members(string vote_account, string password, int type, List vote_ids, string vote_count) 245 | { 246 | Invoke(System.Reflection.MethodBase.GetCurrentMethod().Name, "Cocos_PublishVotes", vote_account, password, type, vote_ids, vote_count); 247 | } 248 | 249 | 250 | 251 | 252 | private static void apiNameMaping(string apiName, string realName) 253 | { 254 | if (!nameMap.ContainsKey(realName)) 255 | { 256 | nameMap.Add(realName, apiName); 257 | } 258 | } 259 | 260 | private static string getAPIName(string realName) 261 | { 262 | if (nameMap.ContainsKey(realName)) 263 | { 264 | return nameMap[realName]; 265 | } 266 | return realName; 267 | } 268 | 269 | private static JSONObject params2JSON(params object[] objs) 270 | { 271 | JSONObject objP = new JSONObject(JSONObject.Type.ARRAY); 272 | foreach (var item in objs) 273 | { 274 | string s = item as string; 275 | if (null != s) 276 | { 277 | objP.Add(s); 278 | } 279 | else if (IsNumber(item)) 280 | { 281 | objP.Add(Convert.ToInt32(item)); 282 | } 283 | else if (item is bool) 284 | { 285 | objP.Add(Convert.ToInt32((bool)item)); 286 | } 287 | else if (item is List) 288 | { 289 | JSONObject objL = new JSONObject(JSONObject.Type.ARRAY); 290 | foreach(var o in (item as List)) 291 | { 292 | objL.Add(o); 293 | } 294 | objP.Add(objL); 295 | } 296 | } 297 | return objP; 298 | } 299 | 300 | private static void Invoke(string api, string f, params object[] arr) 301 | { 302 | apiNameMaping(api, f); 303 | JSONObject obj = new JSONObject(JSONObject.Type.OBJECT); 304 | obj.AddField("f", f); 305 | obj.AddField("p", params2JSON(arr)); 306 | 307 | #if !UNITY_EDITOR 308 | BCX_reflectionCall(obj.ToString()); 309 | #endif 310 | } 311 | 312 | private static void RunInUnityMainThread(System.Action action) 313 | { 314 | UnityMainThreadDispatcher dispatcher = UnityMainThreadDispatcher.Instance(); 315 | if (null == dispatcher) 316 | { 317 | Debug.Log("UnityMainThreadDispatcher is null, please add UnityMainThreadDispatcher.prefab to your scene"); 318 | return; 319 | } 320 | dispatcher.Enqueue(action); 321 | } 322 | 323 | /* 324 | * Native Related 325 | * 326 | */ 327 | // delegate signature for callbacks from SDKBOX runtime. 328 | public delegate void BCXBridgeCallbackDelegate(string method, string error); 329 | 330 | [MonoPInvokeCallback(typeof(BCXBridgeCallbackDelegate))] 331 | private static void BCXBridgeCallback(string method, string json) 332 | { 333 | RunInUnityMainThread(() => { 334 | string evt = method; 335 | // Debug.Log("BCXBridgeCallback:" + evt); 336 | // Debug.Log("BCXBridgeCallback:" + json); 337 | switch (method) 338 | { 339 | case "get_version_info": 340 | { 341 | JSONObject jObj = new JSONObject(json); 342 | JSONObject codeObj = jObj.GetField("code"); 343 | JSONObject dataObj = jObj.GetField("data"); 344 | if (1 == codeObj.n) { 345 | dataObj.str = BCXWrapperBase.VERSION + "-" + dataObj.str; 346 | } 347 | jObj.SetField("data", dataObj); 348 | json = jObj.ToString(); 349 | break; 350 | } 351 | default: { 352 | evt = getAPIName(evt); 353 | // Debug.Log("BCXBridgeCallback not handled"); 354 | break; 355 | } 356 | } 357 | BCXWrapperIOS.BCXEvent.Invoke(evt, json); 358 | }); 359 | } 360 | 361 | 362 | [DllImport("__Internal")] 363 | public static extern void BCX_set_unity_callback(BCXBridgeCallbackDelegate callback); 364 | 365 | [DllImport("__Internal")] 366 | public static extern void BCX_reflectionCall(string json); 367 | 368 | [DllImport("__Internal")] 369 | public static extern void BCX_connect(string chainId, string nodeUrlString, string faucetUrl, string coreAsset, bool isOpenLog); 370 | 371 | [DllImport("__Internal")] 372 | public static extern void BCX_get_version_info(); 373 | 374 | [DllImport("__Internal")] 375 | public static extern void BCX_create_account(string account, string password, string accountType, bool isAutoLogin); 376 | 377 | } 378 | } 379 | 380 | #endif 381 | 382 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/BCXWrapperIOS.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34ff065bc977840238cb05dcde83047e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a83f7273d0ba4375ada4a3791779e4b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/android_export_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/unity/bcx/Assets/BCX/Document/android_export_setting.png -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/android_export_setting.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4224935b14e3c45cabf4fe6431341440 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 5 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 0 27 | seamlessCubemap: 0 28 | textureFormat: 1 29 | maxTextureSize: 2048 30 | textureSettings: 31 | serializedVersion: 2 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapU: -1 36 | wrapV: -1 37 | wrapW: -1 38 | nPOTScale: 1 39 | lightmap: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spritePixelsToUnits: 100 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spriteGenerateFallbackPhysicsShape: 1 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | singleChannelComponent: 0 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - serializedVersion: 2 60 | buildTarget: DefaultTexturePlatform 61 | maxTextureSize: 2048 62 | resizeAlgorithm: 0 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | androidETC2FallbackOverride: 0 70 | spriteSheet: 71 | serializedVersion: 2 72 | sprites: [] 73 | outline: [] 74 | physicsShape: [] 75 | bones: [] 76 | spriteID: 77 | vertices: [] 78 | indices: 79 | edges: [] 80 | weights: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/readme.md: -------------------------------------------------------------------------------- 1 | # BCX-Unity-SDK 2 | 3 | ## Introduction 4 | 5 | The BCX-Unity-SDK is based on [BCX-Android-SDK](https://github.com/Cocos-BCX/AndroidSdk) and [BCX-iOS-SDK](https://github.com/Cocos-BCX/iOSSDK) , which provide a series of interfaces for Unity to operate the BCX blockchain, allowing users to handle logins, transfers, trading assets, calling contracts, and more. 6 | 7 | ## Environment 8 | 9 | ### Android 10 | 11 | 1. [Android Studio](https://developer.android.com/studio) 12 | 13 | ### iOS 14 | 15 | 1. [CocoaPods](https://cocoapods.org/) 16 | 2. Xcode 17 | 18 | ### Unity 19 | 20 | 1. [Untiy 2018.1+](https://unity.com/) 21 | 2. git 22 | 23 | ## Sample 24 | 25 | we provide a sample scene for test purposes, for invoke BCX-Unity-SDK APIs. it's located at `Assets/BCX/Sample/` 26 | 27 | ### Test 28 | 29 | #### Android 30 | 31 | 1. Open Unity 32 | 2. Import BCX-Unity-SDK package 33 | 3. Export Android project in Unity, with follow settings: 34 | 35 | ![](./android_export_setting.png) 36 | 37 | 4. Open the exported project with Android Studio 38 | 5. Compile, Run 39 | 40 | __NOTE1__: When compiling on Android, you may got a similar error in `Error: Cannot fit requested classes in a single dex file (# methods: 149346 > 65536). This is because Android has a limit on the number of methods in a single jar. 41 | 42 | you can fix it with the solution below: 43 | 44 | build.gradle 45 | ```gradle 46 | ... 47 | dependencies { 48 | ... 49 | 50 | implementation 'com.android.support:multidex:1.0.3' //add 51 | } 52 | ... 53 | android { 54 | 55 | defaultConfig { 56 | ... 57 | 58 | multiDexEnabled true //add 59 | } 60 | } 61 | ... 62 | ``` 63 | 64 | ref url: https://stackoverflow.com/questions/48249633/errorcannot-fit-requested-classes-in-a-single-dex-file-try-supplying-a-main-dex . 65 | 66 | __NOTE2__: if your application is target Android 9 (API level 28) or higher, you might got "RPC Connect failed", when connect to BCX blockchain. one possible reason is "CLEARTEXT communication is not permitted". you can modify AndroidManifest.xml like below: 67 | 68 | AndroidManifest.xml : 69 | ```xml 70 | 71 | 72 | 76 | ... 77 | 78 | 79 | ``` 80 | 81 | ref url: https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted 82 | 83 | #### iOS 84 | 85 | 1. Open Unity 86 | 2. Import BCX-Unity-SDK package 87 | 3. Export iOS project in Unity 88 | 4. run `pod install` under the exported iOS project. (if you don't have `CocoaPods` installed, install it first) 89 | 5. open `Unity-iPhone.xcworkspace` with Xcode 90 | 6. Modify the configuration of `Secp256k1_A` as shown in the figure: 91 | 92 | ![](./xcode_secp_target_setting.png) 93 | 94 | 7. Compile, Run 95 | 96 | ## Hint 97 | 98 | 1. Many interfaces in BCX-iOS-SDK only receive id. id and name are both accepted in BCX-Android-SDK, so it is recommended to use id as much as possible. for example: 99 | 100 | ```C# 101 | public static void calculate_invoking_contract_fee(string strAccount, string feeAssetSymbol, string contractId, string functionName, string param) 102 | ``` 103 | 104 | you can pass "COCOS" or "1.3.0" to feeAssetSymbol parameter in Android. 105 | But in iOS, only "1.3.0" can be passed. 106 | 107 | ## API 108 | 109 | >> 110 | ```C# 111 | public static void connect(string chainId, string nodeUrl, string faucetUrl, string coreAsset, bool isOpenLog) 112 | ``` 113 | 114 | >>accountType: "ACCOUNT", "WALLET" 115 | ```C# 116 | public static void create_account(string strAccountName, string strPassword, string accountType, bool isAutoLogin) 117 | ``` 118 | 119 | >> 120 | ```C# 121 | public static void get_dao_account_objects() 122 | ``` 123 | 124 | >> 125 | ```C# 126 | public static void get_accounts(string accountId) 127 | ``` 128 | 129 | >> 130 | ```C# 131 | public static void get_full_accounts(string names_or_id, bool subscribe) 132 | ``` 133 | 134 | >> 135 | ```C# 136 | public static void lookup_nh_asset(List nh_asset_ids_or_hash) 137 | ``` 138 | 139 | >> 140 | ```C# 141 | public static void list_account_nh_asset(string account_id_or_name, List world_view_name_or_ids, int page, int pageSize) 142 | ``` 143 | 144 | >> 145 | ```C# 146 | public static void list_account_nh_asset_order(string account_id_or_name, int pageSize, int page) 147 | ``` 148 | 149 | >> 150 | ```C# 151 | public static void list_nh_asset_order(string asset_id_or_symbol, string world_view_name_or_ids, string baseDescribe, int pageSize, int page) 152 | ``` 153 | 154 | >> 155 | ```C# 156 | public static void lookup_world_view(List world_view_names) 157 | ``` 158 | 159 | >> 160 | ```C# 161 | public static void list_nh_asset_by_creator(string account_id, string worldView, int page, int pageSize) 162 | ``` 163 | 164 | >> 165 | ```C# 166 | public static void transfer_nh_asset(string password, string account_from, string account_to, string nh_asset_ids) 167 | ``` 168 | 169 | >> 170 | ```C# 171 | public static void delete_nh_asset(string fee_paying_account, string password, string nhasset_ids) 172 | ``` 173 | 174 | >> 175 | ```C# 176 | public static void cancel_nh_asset_order(string fee_paying_account, string password, string order_id) 177 | ``` 178 | 179 | >> 180 | ```C# 181 | public static void buy_nh_asset(string fee_paying_account, string password, string order_Id) 182 | ``` 183 | 184 | >> 185 | ```C# 186 | public static void create_nh_asset_order(string otcaccount, string seller, string password, string pending_order_nh_asset, string pending_order_fee, string pending_order_fee_symbol, string pending_order_memo, string pending_order_price, string pending_order_price_symbol, long pending_order_valid_time_second) 187 | ``` 188 | 189 | >> 190 | ```C# 191 | public static void upgrade_to_lifetime_member(string upgrade_account_id_or_symbol, string upgrade_account_password) 192 | ``` 193 | 194 | >> 195 | ```C# 196 | public static void get_contract(string contractNameOrId) 197 | ``` 198 | 199 | >> 200 | ```C# 201 | public static void password_login(string strAccountName, string strPassword) 202 | ``` 203 | 204 | >> 205 | ```C# 206 | public static void import_keystore(string keystore, string password, string accountType) 207 | ``` 208 | 209 | >> 210 | ```C# 211 | public static void export_keystore(string accountName, string password) 212 | ``` 213 | 214 | >> 215 | ```C# 216 | public static void import_wif_key(string wifKey, string password, string accountType) 217 | ``` 218 | 219 | >> 220 | ```C# 221 | public static void export_private_key(string accountName, string password) 222 | ``` 223 | 224 | >> 225 | ```C# 226 | public static void lookup_asset_symbols(string assetsSymbolOrId) 227 | ``` 228 | 229 | >> 230 | ```C# 231 | public static void invoking_contract(string strAccount, string password, string contractNameOrId, string functionName, string param) 232 | ``` 233 | 234 | >> 235 | ```C# 236 | public static void transfer(string password, string strFrom, string strTo, string strAmount, string strAssetSymbol, string strMemo) 237 | ``` 238 | 239 | >> 240 | ```C# 241 | public static void get_block(string nBlockNumber) 242 | ``` 243 | 244 | >> 245 | ```C# 246 | public static void get_account_history(string accountName, int nLimit) 247 | ``` 248 | 249 | >> 250 | ```C# 251 | public static void get_account_balances(string accountId, string assetsId) 252 | ``` 253 | 254 | >> 255 | ```C# 256 | public static void get_block_header(double nBlockNumber) 257 | ``` 258 | 259 | >> 260 | ```C# 261 | public static void get_dynamic_global_properties() 262 | ``` 263 | 264 | >> 265 | ```C# 266 | public static void get_transaction_in_block_info(string tr_id) 267 | ``` 268 | 269 | >> 270 | ```C# 271 | public static void get_transaction_by_id(string tr_id) 272 | ``` 273 | 274 | >> 275 | ```C# 276 | public static void decrypt_memo_message(string accountName, string password, string mMemoJson) 277 | ``` 278 | 279 | >>Get the version of BCX-Unity-SDK 280 | 281 | >>The version structure is {BCX-Unity-SDK-Version}-{BCX-iOS-SDK-Version/BCX-Android-SDK-Version} 282 | ```C# 283 | public static void get_version_info() 284 | ``` 285 | 286 | >> 287 | ```C# 288 | public static void log_out(string accountName) 289 | ``` 290 | 291 | >> 292 | ```C# 293 | public static void get_estimation_gas(string amount) 294 | ``` 295 | 296 | >> 297 | ```C# 298 | public static void update_collateral_for_gas(string mortgagor, string password, string beneficiary, string amount) 299 | ``` 300 | 301 | >> 302 | ```C# 303 | public static void get_vesting_balances(string accountNameOrId) 304 | ``` 305 | 306 | >> 307 | ```C# 308 | public static void receive_vesting_balances(string accountNameOrId, string password, string awardId) 309 | ``` 310 | 311 | >> 312 | ```C# 313 | public static void get_committee_members(string support_account) 314 | ``` 315 | 316 | >> 317 | ```C# 318 | public static void get_witnesses_members(string support_account) 319 | ``` 320 | 321 | >> type: 1 -> witnesses, 0 -> committee 322 | ```C# 323 | public static void vote_members(string vote_account, string password, int type, List vote_ids, string vote_count) 324 | ``` 325 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/readme.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ddcb22a18d8247e29814cbd87ce4605 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/versions.md: -------------------------------------------------------------------------------- 1 | 2 | # Versions 3 | 4 | 5 | ## 1.0.0 6 | 7 | Release Date: 2019.11.15 8 | 9 | ChangeLog: 10 | 11 | * remove API which is not supported by iOS/Android 12 | * add gas,vote APIs 13 | 14 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/versions.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80b2dc58cc0f84c39809a375f67a72de 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/xcode_secp_target_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/unity/bcx/Assets/BCX/Document/xcode_secp_target_setting.png -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Document/xcode_secp_target_setting.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f585e5fff13934458859567b96206b04 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 5 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 0 27 | seamlessCubemap: 0 28 | textureFormat: 1 29 | maxTextureSize: 2048 30 | textureSettings: 31 | serializedVersion: 2 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapU: -1 36 | wrapV: -1 37 | wrapW: -1 38 | nPOTScale: 1 39 | lightmap: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spritePixelsToUnits: 100 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spriteGenerateFallbackPhysicsShape: 1 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | singleChannelComponent: 0 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - serializedVersion: 2 60 | buildTarget: DefaultTexturePlatform 61 | maxTextureSize: 2048 62 | resizeAlgorithm: 0 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | androidETC2FallbackOverride: 0 70 | spriteSheet: 71 | serializedVersion: 2 72 | sprites: [] 73 | outline: [] 74 | physicsShape: [] 75 | bones: [] 76 | spriteID: 77 | vertices: [] 78 | indices: 79 | edges: [] 80 | weights: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ace2b6d06d01847cf95d68cdd67e9386 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/ExtractTarGz.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.IO.Compression; 4 | using System.Text; 5 | 6 | public class Tar 7 | { 8 | /// 9 | /// Extracts a .tar.gz archive to the specified directory. 10 | /// 11 | /// The .tar.gz to decompress and extract. 12 | /// Output directory to write the files. 13 | public static void ExtractTarGz(string filename, string outputDir) 14 | { 15 | using (var stream = File.OpenRead(filename)) 16 | ExtractTarGz(stream, outputDir); 17 | } 18 | 19 | /// 20 | /// Extracts a .tar.gz archive stream to the specified directory. 21 | /// 22 | /// The .tar.gz to decompress and extract. 23 | /// Output directory to write the files. 24 | public static void ExtractTarGz(Stream stream, string outputDir) 25 | { 26 | // A GZipStream is not seekable, so copy it first to a MemoryStream 27 | using (var gzip = new GZipStream(stream, CompressionMode.Decompress)) 28 | { 29 | const int chunk = 4096; 30 | using (var memStr = new MemoryStream()) 31 | { 32 | int read; 33 | var buffer = new byte[chunk]; 34 | do 35 | { 36 | read = gzip.Read(buffer, 0, chunk); 37 | memStr.Write(buffer, 0, read); 38 | } while (read == chunk); 39 | 40 | memStr.Seek(0, SeekOrigin.Begin); 41 | ExtractTar(memStr, outputDir); 42 | } 43 | } 44 | } 45 | 46 | /// 47 | /// Extractes a tar archive to the specified directory. 48 | /// 49 | /// The .tar to extract. 50 | /// Output directory to write the files. 51 | public static void ExtractTar(string filename, string outputDir) 52 | { 53 | using (var stream = File.OpenRead(filename)) 54 | ExtractTar(stream, outputDir); 55 | } 56 | 57 | /// 58 | /// Extractes a tar archive to the specified directory. 59 | /// 60 | /// The .tar to extract. 61 | /// Output directory to write the files. 62 | public static void ExtractTar(Stream stream, string outputDir) 63 | { 64 | var buffer = new byte[100]; 65 | while (true) 66 | { 67 | stream.Read(buffer, 0, 100); 68 | var name = Encoding.ASCII.GetString(buffer).Trim('\0'); 69 | if (null == name || 0 == name.Length) 70 | { 71 | break; 72 | } 73 | stream.Seek(24, SeekOrigin.Current); 74 | stream.Read(buffer, 0, 12); 75 | var sizeString = Encoding.ASCII.GetString(buffer, 0, 12).Trim('\r','\n','\0', ' '); 76 | var size = Convert.ToInt64(sizeString, 8); 77 | 78 | stream.Seek(376L, SeekOrigin.Current); 79 | 80 | var output = Path.Combine(outputDir, name); 81 | if (!Directory.Exists(Path.GetDirectoryName(output))) 82 | { 83 | Directory.CreateDirectory(Path.GetDirectoryName(output)); 84 | } 85 | if (!name.EndsWith("/")) { 86 | using (var str = File.Open(output, FileMode.OpenOrCreate, FileAccess.Write)) 87 | { 88 | var buf = new byte[size]; 89 | stream.Read(buf, 0, buf.Length); 90 | str.Write(buf, 0, buf.Length); 91 | } 92 | } 93 | 94 | var pos = stream.Position; 95 | 96 | var offset = 512 - (pos % 512); 97 | if (offset == 512) 98 | offset = 0; 99 | 100 | stream.Seek(offset, SeekOrigin.Current); 101 | } 102 | } 103 | } 104 | 105 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/ExtractTarGz.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee1f1002ede061b47aea3031e1f42e6d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/ProjectFileHook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml; 6 | using System.Xml.Linq; 7 | using System.Collections.Generic; 8 | using System.Text.RegularExpressions; 9 | using UnityEngine; 10 | using UnityEditor; 11 | #if UNITY_5_6_OR_NEWER 12 | using UnityEditor.Build; 13 | #endif 14 | using UnityEditor.Callbacks; 15 | 16 | [InitializeOnLoad] 17 | public class ProjectFileHook 18 | { 19 | [PostProcessBuildAttribute] 20 | public static void OnPostProcessBuild(BuildTarget target, string path) 21 | { 22 | if (BuildTarget.Android == target) { 23 | string buildGradle = path + "/" + Application.productName + "/build.gradle"; 24 | fixBuildGradle(buildGradle); 25 | } else if (BuildTarget.iOS == target) { 26 | geniOSSDK(path); 27 | } 28 | } 29 | 30 | private static void fixBuildGradle(string path) 31 | { 32 | if (!System.IO.File.Exists(path)) 33 | { 34 | Debug.Log("ERROR! build.gradle not exist:" + path); 35 | return; 36 | } 37 | 38 | // remove follow lines: 39 | // compile(name: 'bcx_sdk', ext:'aar') 40 | // compile(name: 'bcxbridge', ext:'aar') 41 | List lines = new List(); 42 | foreach (string line in File.ReadAllLines(path)) 43 | { 44 | if (line.Contains("compile(name: 'bcx_sdk', ext:'aar')") 45 | || line.Contains("compile(name: 'bcxbridge', ext:'aar')") 46 | || line.Contains("implementation(name: 'bcx_sdk', ext:'aar')") 47 | || line.Contains("implementation(name: 'bcxbridge', ext:'aar')") 48 | ) 49 | { 50 | continue; 51 | } 52 | lines.Add(line); 53 | } 54 | File.WriteAllLines(path, lines.ToArray()); 55 | } 56 | 57 | private static void geniOSSDK(string path) 58 | { 59 | extractTarGz( 60 | Utils.PathCombine(Application.dataPath, "BCX", "Editor", "iOS", "BCXUnitySDK.tar.gz"), 61 | Utils.PathCombine(path, "BCX")); 62 | 63 | string podfile = Utils.PathCombine(path, "Podfile"); 64 | if (!System.IO.File.Exists(podfile)) 65 | { 66 | string podfileContent = 67 | "platform :ios, '8.0'\r\n" 68 | +"target 'Unity-iPhone' do\r\n" 69 | +" use_frameworks!\r\n" 70 | +" pod 'CocosSDK', :path => './BCX/BCXUnitySDK/'\r\n" 71 | +" target 'Unity-iPhone Tests' do\r\n" 72 | +" inherit! :search_paths\r\n" 73 | +" end\r\n" 74 | +"end\r\n"; 75 | System.IO.File.WriteAllText(podfile, podfileContent); 76 | } 77 | } 78 | 79 | private static void extractTarGz(string gzfile, string dstPath) 80 | { 81 | if (Directory.Exists(dstPath)) 82 | { 83 | Directory.Delete(dstPath, true); 84 | } 85 | Tar.ExtractTarGz(gzfile, dstPath); 86 | } 87 | 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/ProjectFileHook.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d177bced022464b769eab1ecfb5c9bb7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/Utils.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | public class Utils 4 | { 5 | public static string PathCombine(string path, params string[] parts) 6 | { 7 | string s = path; 8 | foreach(var part in parts) 9 | { 10 | s = Path.Combine(s, part); 11 | } 12 | return s; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25768f17ae69c47c3a626ccac344714c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/iOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a45f156ee777f4aa19d4ffee74e7053e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/iOS/BCXUnitySDK.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/unity/bcx/Assets/BCX/Editor/iOS/BCXUnitySDK.tar.gz -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Editor/iOS/BCXUnitySDK.tar.gz.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba8117bb93fd34e689a7c3aa17075f3e 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5d9c8ad660db4aef9e0638b772013fe 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70fd5928a4ad34861848f8e97834d4fa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Plugins/Android/bcx_sdk.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/unity/bcx/Assets/BCX/Plugins/Android/bcx_sdk.aar -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Plugins/Android/bcx_sdk.aar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50710b649d7a94620b1e21aac7ead2bf 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | isPreloaded: 0 9 | isOverridable: 0 10 | platformData: 11 | - first: 12 | Android: Android 13 | second: 14 | enabled: 1 15 | settings: {} 16 | - first: 17 | Any: 18 | second: 19 | enabled: 0 20 | settings: {} 21 | - first: 22 | Editor: Editor 23 | second: 24 | enabled: 0 25 | settings: 26 | DefaultValueInitialized: true 27 | userData: 28 | assetBundleName: 29 | assetBundleVariant: 30 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Plugins/Android/bcxbridge.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cocos-BCX/UnitySDK/314c6b1f66bc7b43fbb887f540aafd3dea51eace/unity/bcx/Assets/BCX/Plugins/Android/bcxbridge.aar -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Plugins/Android/bcxbridge.aar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5743ac31cdf6d4326a3ef64e170686ab 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | isPreloaded: 0 9 | isOverridable: 0 10 | platformData: 11 | - first: 12 | Android: Android 13 | second: 14 | enabled: 1 15 | settings: {} 16 | - first: 17 | Any: 18 | second: 19 | enabled: 0 20 | settings: {} 21 | - first: 22 | Editor: Editor 23 | second: 24 | enabled: 0 25 | settings: 26 | DefaultValueInitialized: true 27 | userData: 28 | assetBundleName: 29 | assetBundleVariant: 30 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Plugins/iOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b59d0fddc766842298776f69b56780b0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Sample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f704ae4b4f98ae41a0bce26658850c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Sample/BCXTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 176eea46ad7ca40999f7d64c0e2a2221 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/Sample/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c9720ab356a0642a771bea13969a05 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/UnityMainThreadDispatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class UnityMainThreadDispatcher : MonoBehaviour { 7 | 8 | private static readonly Queue _executionQueue = new Queue(); 9 | 10 | public void Update() 11 | { 12 | lock (_executionQueue) 13 | { 14 | while (_executionQueue.Count > 0) 15 | { 16 | _executionQueue.Dequeue().Invoke(); 17 | } 18 | } 19 | } 20 | 21 | /// 22 | /// Locks the queue and adds the IEnumerator to the queue 23 | /// 24 | /// IEnumerator function that will be executed from the main thread. 25 | public void Enqueue(IEnumerator action) 26 | { 27 | lock (_executionQueue) 28 | { 29 | _executionQueue.Enqueue(() => { 30 | StartCoroutine(action); 31 | }); 32 | } 33 | } 34 | 35 | /// 36 | /// Locks the queue and adds the Action to the queue 37 | /// 38 | /// function that will be executed from the main thread. 39 | public void Enqueue(Action action) 40 | { 41 | Enqueue(ActionWrapper(action)); 42 | } 43 | IEnumerator ActionWrapper(Action a) 44 | { 45 | a(); 46 | yield return null; 47 | } 48 | 49 | 50 | private static UnityMainThreadDispatcher _instance = null; 51 | 52 | public static bool Exists() 53 | { 54 | return _instance != null; 55 | } 56 | 57 | public static UnityMainThreadDispatcher Instance() 58 | { 59 | //if (!Exists()) 60 | //{ 61 | // throw new Exception("UnityMainThreadDispatcher could not find the UnityMainThreadDispatcher object. Please ensure you have added the MainThreadExecutor Prefab to your scene."); 62 | //} 63 | return _instance; 64 | } 65 | 66 | 67 | void Awake() 68 | { 69 | if (_instance == null) 70 | { 71 | _instance = this; 72 | DontDestroyOnLoad(this.gameObject); 73 | } 74 | } 75 | 76 | void OnDestroy() 77 | { 78 | _instance = null; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /unity/bcx/Assets/BCX/UnityMainThreadDispatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc3d21ac665dce4b960783ad3c44e4b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5ff25406e1df49d4b9f6c1d314ee3eb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb09dc3fd660f4c1f88a545a821e5f08 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/Editor/JSONChecker.cs: -------------------------------------------------------------------------------- 1 | //#define PERFTEST //For testing performance of parse/stringify. Turn on editor profiling to see how we're doing 2 | 3 | using UnityEngine; 4 | using UnityEditor; 5 | #if UNITY_2017_1_OR_NEWER 6 | using UnityEngine.Networking; 7 | #endif 8 | 9 | /* 10 | Copyright (c) 2010-2019 Matt Schoen 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. 29 | */ 30 | 31 | public class JSONChecker : EditorWindow { 32 | string JSON = @"{ 33 | ""TestObject"": { 34 | ""SomeText"": ""Blah"", 35 | ""SomeObject"": { 36 | ""SomeNumber"": 42, 37 | ""SomeFloat"": 13.37, 38 | ""SomeBool"": true, 39 | ""SomeNull"": null 40 | }, 41 | 42 | ""SomeEmptyObject"": { }, 43 | ""SomeEmptyArray"": [ ], 44 | ""EmbeddedObject"": ""{\""field\"":\""Value with \\\""escaped quotes\\\""\""}"" 45 | } 46 | }"; //dat string literal... 47 | string URL = ""; 48 | JSONObject j; 49 | [MenuItem("Window/JSONChecker")] 50 | static void Init() { 51 | GetWindow(typeof(JSONChecker)); 52 | } 53 | void OnGUI() { 54 | JSON = EditorGUILayout.TextArea(JSON); 55 | GUI.enabled = !string.IsNullOrEmpty(JSON); 56 | if(GUILayout.Button("Check JSON")) { 57 | #if PERFTEST 58 | Profiler.BeginSample("JSONParse"); 59 | j = JSONObject.Create(JSON); 60 | Profiler.EndSample(); 61 | Profiler.BeginSample("JSONStringify"); 62 | j.ToString(true); 63 | Profiler.EndSample(); 64 | #else 65 | j = JSONObject.Create(JSON); 66 | #endif 67 | Debug.Log(j.ToString(true)); 68 | } 69 | EditorGUILayout.Separator(); 70 | URL = EditorGUILayout.TextField("URL", URL); 71 | if (GUILayout.Button("Get JSON")) { 72 | Debug.Log(URL); 73 | #if UNITY_2017_1_OR_NEWER 74 | var test = new UnityWebRequest(URL); 75 | test.SendWebRequest(); 76 | while (!test.isDone && !test.isNetworkError) ; 77 | #else 78 | var test = new WWW(URL); 79 | while (!test.isDone) ; 80 | #endif 81 | if (!string.IsNullOrEmpty(test.error)) { 82 | Debug.Log(test.error); 83 | } else { 84 | #if UNITY_2017_1_OR_NEWER 85 | var text = test.downloadHandler.text; 86 | #else 87 | var text = test.text; 88 | #endif 89 | Debug.Log(text); 90 | j = new JSONObject(text); 91 | Debug.Log(j.ToString(true)); 92 | } 93 | } 94 | if(j) { 95 | //Debug.Log(System.GC.GetTotalMemory(false) + ""); 96 | if(j.type == JSONObject.Type.NULL) 97 | GUILayout.Label("JSON fail:\n" + j.ToString(true)); 98 | else 99 | GUILayout.Label("JSON success:\n" + j.ToString(true)); 100 | 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/Editor/JSONChecker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 6c5a625d29393ed4da8d9150a629fb35 3 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/JSONObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: f71819923b555d14ab64ae2044718de9 3 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2019 Matt Schoen 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d65b4117f5b5c3341947d0a81786e2cd 3 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/VectorTemplates.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | /* 4 | Copyright (c) 2010-2019 Matt Schoen 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | 25 | public static partial class JSONTemplates { 26 | 27 | /* 28 | * Vector2 29 | */ 30 | public static Vector2 ToVector2(JSONObject obj) { 31 | float x = obj["x"] ? obj["x"].f : 0; 32 | float y = obj["y"] ? obj["y"].f : 0; 33 | return new Vector2(x, y); 34 | } 35 | public static JSONObject FromVector2(Vector2 v) { 36 | JSONObject vdata = JSONObject.obj; 37 | if(v.x != 0) vdata.AddField("x", v.x); 38 | if(v.y != 0) vdata.AddField("y", v.y); 39 | return vdata; 40 | } 41 | /* 42 | * Vector3 43 | */ 44 | public static JSONObject FromVector3(Vector3 v) { 45 | JSONObject vdata = JSONObject.obj; 46 | if(v.x != 0) vdata.AddField("x", v.x); 47 | if(v.y != 0) vdata.AddField("y", v.y); 48 | if(v.z != 0) vdata.AddField("z", v.z); 49 | return vdata; 50 | } 51 | public static Vector3 ToVector3(JSONObject obj) { 52 | float x = obj["x"] ? obj["x"].f : 0; 53 | float y = obj["y"] ? obj["y"].f : 0; 54 | float z = obj["z"] ? obj["z"].f : 0; 55 | return new Vector3(x, y, z); 56 | } 57 | /* 58 | * Vector4 59 | */ 60 | public static JSONObject FromVector4(Vector4 v) { 61 | JSONObject vdata = JSONObject.obj; 62 | if(v.x != 0) vdata.AddField("x", v.x); 63 | if(v.y != 0) vdata.AddField("y", v.y); 64 | if(v.z != 0) vdata.AddField("z", v.z); 65 | if(v.w != 0) vdata.AddField("w", v.w); 66 | return vdata; 67 | } 68 | public static Vector4 ToVector4(JSONObject obj) { 69 | float x = obj["x"] ? obj["x"].f : 0; 70 | float y = obj["y"] ? obj["y"].f : 0; 71 | float z = obj["z"] ? obj["z"].f : 0; 72 | float w = obj["w"] ? obj["w"].f : 0; 73 | return new Vector4(x, y, z, w); 74 | } 75 | /* 76 | * Matrix4x4 77 | */ 78 | public static JSONObject FromMatrix4x4(Matrix4x4 m) { 79 | JSONObject mdata = JSONObject.obj; 80 | if(m.m00 != 0) mdata.AddField("m00", m.m00); 81 | if(m.m01 != 0) mdata.AddField("m01", m.m01); 82 | if(m.m02 != 0) mdata.AddField("m02", m.m02); 83 | if(m.m03 != 0) mdata.AddField("m03", m.m03); 84 | if(m.m10 != 0) mdata.AddField("m10", m.m10); 85 | if(m.m11 != 0) mdata.AddField("m11", m.m11); 86 | if(m.m12 != 0) mdata.AddField("m12", m.m12); 87 | if(m.m13 != 0) mdata.AddField("m13", m.m13); 88 | if(m.m20 != 0) mdata.AddField("m20", m.m20); 89 | if(m.m21 != 0) mdata.AddField("m21", m.m21); 90 | if(m.m22 != 0) mdata.AddField("m22", m.m22); 91 | if(m.m23 != 0) mdata.AddField("m23", m.m23); 92 | if(m.m30 != 0) mdata.AddField("m30", m.m30); 93 | if(m.m31 != 0) mdata.AddField("m31", m.m31); 94 | if(m.m32 != 0) mdata.AddField("m32", m.m32); 95 | if(m.m33 != 0) mdata.AddField("m33", m.m33); 96 | return mdata; 97 | } 98 | public static Matrix4x4 ToMatrix4x4(JSONObject obj) { 99 | Matrix4x4 result = new Matrix4x4(); 100 | if(obj["m00"]) result.m00 = obj["m00"].f; 101 | if(obj["m01"]) result.m01 = obj["m01"].f; 102 | if(obj["m02"]) result.m02 = obj["m02"].f; 103 | if(obj["m03"]) result.m03 = obj["m03"].f; 104 | if(obj["m10"]) result.m10 = obj["m10"].f; 105 | if(obj["m11"]) result.m11 = obj["m11"].f; 106 | if(obj["m12"]) result.m12 = obj["m12"].f; 107 | if(obj["m13"]) result.m13 = obj["m13"].f; 108 | if(obj["m20"]) result.m20 = obj["m20"].f; 109 | if(obj["m21"]) result.m21 = obj["m21"].f; 110 | if(obj["m22"]) result.m22 = obj["m22"].f; 111 | if(obj["m23"]) result.m23 = obj["m23"].f; 112 | if(obj["m30"]) result.m30 = obj["m30"].f; 113 | if(obj["m31"]) result.m31 = obj["m31"].f; 114 | if(obj["m32"]) result.m32 = obj["m32"].f; 115 | if(obj["m33"]) result.m33 = obj["m33"].f; 116 | return result; 117 | } 118 | /* 119 | * Quaternion 120 | */ 121 | public static JSONObject FromQuaternion(Quaternion q) { 122 | JSONObject qdata = JSONObject.obj; 123 | if(q.w != 0) qdata.AddField("w", q.w); 124 | if(q.x != 0) qdata.AddField("x", q.x); 125 | if(q.y != 0) qdata.AddField("y", q.y); 126 | if(q.z != 0) qdata.AddField("z", q.z); 127 | return qdata; 128 | } 129 | public static Quaternion ToQuaternion(JSONObject obj) { 130 | float x = obj["x"] ? obj["x"].f : 0; 131 | float y = obj["y"] ? obj["y"].f : 0; 132 | float z = obj["z"] ? obj["z"].f : 0; 133 | float w = obj["w"] ? obj["w"].f : 0; 134 | return new Quaternion(x, y, z, w); 135 | } 136 | /* 137 | * Color 138 | */ 139 | public static JSONObject FromColor(Color c) { 140 | JSONObject cdata = JSONObject.obj; 141 | if(c.r != 0) cdata.AddField("r", c.r); 142 | if(c.g != 0) cdata.AddField("g", c.g); 143 | if(c.b != 0) cdata.AddField("b", c.b); 144 | if(c.a != 0) cdata.AddField("a", c.a); 145 | return cdata; 146 | } 147 | public static Color ToColor(JSONObject obj) { 148 | Color c = new Color(); 149 | for(int i = 0; i < obj.Count; i++) { 150 | switch(obj.keys[i]) { 151 | case "r": c.r = obj[i].f; break; 152 | case "g": c.g = obj[i].f; break; 153 | case "b": c.b = obj[i].f; break; 154 | case "a": c.a = obj[i].f; break; 155 | } 156 | } 157 | return c; 158 | } 159 | /* 160 | * Layer Mask 161 | */ 162 | public static JSONObject FromLayerMask(LayerMask l) { 163 | JSONObject result = JSONObject.obj; 164 | result.AddField("value", l.value); 165 | return result; 166 | } 167 | public static LayerMask ToLayerMask(JSONObject obj) { 168 | LayerMask l = new LayerMask {value = (int)obj["value"].n}; 169 | return l; 170 | } 171 | public static JSONObject FromRect(Rect r) { 172 | JSONObject result = JSONObject.obj; 173 | if(r.x != 0) result.AddField("x", r.x); 174 | if(r.y != 0) result.AddField("y", r.y); 175 | if(r.height != 0) result.AddField("height", r.height); 176 | if(r.width != 0) result.AddField("width", r.width); 177 | return result; 178 | } 179 | public static Rect ToRect(JSONObject obj) { 180 | Rect r = new Rect(); 181 | for(int i = 0; i < obj.Count; i++) { 182 | switch(obj.keys[i]) { 183 | case "x": r.x = obj[i].f; break; 184 | case "y": r.y = obj[i].f; break; 185 | case "height": r.height = obj[i].f; break; 186 | case "width": r.width = obj[i].f; break; 187 | } 188 | } 189 | return r; 190 | } 191 | public static JSONObject FromRectOffset(RectOffset r) { 192 | JSONObject result = JSONObject.obj; 193 | if(r.bottom != 0) result.AddField("bottom", r.bottom); 194 | if(r.left != 0) result.AddField("left", r.left); 195 | if(r.right != 0) result.AddField("right", r.right); 196 | if(r.top != 0) result.AddField("top", r.top); 197 | return result; 198 | } 199 | public static RectOffset ToRectOffset(JSONObject obj) { 200 | RectOffset r = new RectOffset(); 201 | for(int i = 0; i < obj.Count; i++) { 202 | switch(obj.keys[i]) { 203 | case "bottom": r.bottom = (int)obj[i].n; break; 204 | case "left": r.left = (int)obj[i].n; break; 205 | case "right": r.right = (int)obj[i].n; break; 206 | case "top": r.top = (int)obj[i].n; break; 207 | } 208 | } 209 | return r; 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/VectorTemplates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 886fb4d7a67d4ce4bb7f51bcc38e20c1 3 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/readme.txt: -------------------------------------------------------------------------------- 1 | ==Author== 2 | [mailto:schoen@defectivestudios.com Matt Schoen] of [http://www.defectivestudios.com Defective Studios] 3 | 4 | ==Download== 5 | [[Media:JSONObject.zip|Download JSONObject.zip]] 6 | 7 | = Intro = 8 | I came across the need to send structured data to and from a server on one of my projects, and figured it would be worth my while to use JSON. When I looked into the issue, I tried a few of the C# implementations listed on [http://json.org json.org], but found them to be too complicated to work with and expand upon. So, I've written a very simple JSONObject class, which can be generically used to encode/decode data into a simple container. This page assumes that you know what JSON is, and how it works. It's rather simple, just go to json.org for a visual description of the encoding format. 9 | 10 | As an aside, this class is pretty central to the [[AssetCloud]] content management system, from Defective Studios. 11 | 12 | Update: The code has been updated to version 1.4 to incorporate user-submitted patches and bug reports. This fixes issues dealing with whitespace in the format, as well as empty arrays and objects, and escaped quotes within strings. 13 | 14 | = Usage = 15 | Users should not have to modify the JSONObject class themselves, and must follow the very simple proceedures outlined below: 16 | 17 | Sample data (in JSON format): 18 | 19 | { 20 | "TestObject": { 21 | "SomeText": "Blah", 22 | "SomeObject": { 23 | "SomeNumber": 42, 24 | "SomeBool": true, 25 | "SomeNull": null 26 | }, 27 | 28 | "SomeEmptyObject": { }, 29 | "SomeEmptyArray": [ ], 30 | "EmbeddedObject": "{\"field\":\"Value with \\\"escaped quotes\\\"\"}" 31 | } 32 | } 33 | 34 | = Features = 35 | 36 | *Decode JSON-formatted strings into a usable data structure 37 | *Encode structured data into a JSON-formatted string 38 | *Interoperable with Dictionary and WWWForm 39 | *Optimized parse/stringify functions -- minimal (unavoidable) garbage creation 40 | *Asynchronous stringify function for serializing lots of data without frame drops 41 | *MaxDepth parsing will skip over nested data that you don't need 42 | *Special (non-compliant) "Baked" object type can store stringified data within parsed objects 43 | *Copy to new JSONObject 44 | *Merge with another JSONObject (experimental) 45 | *Random access (with [int] or [string]) 46 | *ToString() returns JSON data with optional "pretty" flag to include newlines and tabs 47 | *Switch between double and float for numeric storage depending on level of precision needed (and to ensure that numbers are parsed/stringified correctly) 48 | *Supports Infinity and NaN values 49 | *JSONTemplates static class provides serialization functions for common classes like Vector3, Matrix4x4 50 | *Object pool implementation (experimental) 51 | *Handy JSONChecker window to test parsing on sample data 52 | 53 | It should be pretty obvious what this parser can and cannot do. If anyone reading this is a JSON buff (is there such a thing?) please feel free to expand and modify the parser to be more compliant. Currently I am using the .NET System.Convert namespace functions for parsing the data itself. It parses strings and numbers, which was all that I needed of it, but unless the formatting is supported by System.Convert, it may not incorporate all proper JSON strings. Also, having never written a JSON parser before, I don't doubt that I could improve the efficiency or correctness of the parser. It serves my purpose, and hopefully will help you with your project! Let me know if you make any improvements :) 54 | 55 | Also, you JSON buffs (really, who would admit to being a JSON buff...) might also notice from my feature list that this thing isn't exactly to specifications. Here is where it differs: 56 | *"a string" is considered valid JSON. There is an optional "strict" parameter to the parser which will bomb out on such input, in case that matters to you. 57 | *The "Baked" mode is totally made up. 58 | *The "MaxDepth" parsing is totally made up. 59 | *NaN and Infinity aren't officially supported by JSON ([http://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript read more] about this issue... I lol'd @ the first comment on the first answer) 60 | *I have no idea about edge cases in my parsing strategy. I have been using this code for about 3 years now and have only had to modify the parser because other people's use cases (still valid JSON) didn't parse correctly. In my experience, anything that this code generates is parsed just fine. 61 | 62 | == Encoding == 63 | 64 | Encoding is something of a hard-coded process. This is because I have no idea what your data is! It would be great if this were some sort of interface for taking an entire class and encoding it's number/string fields, but it's not. I've come up with a few clever ways of using loops and/or recursive methods to cut down of the amount of code I have to write when I use this tool, but they're pretty project-specific. 65 | 66 | Note: This section used to be WRONG! And now it's OLD! Will update later... this will all still work, but there are now a couple of ways to skin this cat. 67 | 68 | 69 | //Note: your data can only be numbers and strings. This is not a solution for object serialization or anything like that. 70 | JSONObject j = new JSONObject(JSONObject.Type.OBJECT); 71 | //number 72 | j.AddField("field1", 0.5); 73 | //string 74 | j.AddField("field2", "sampletext"); 75 | //array 76 | JSONObject arr = new JSONObject(JSONObject.Type.ARRAY); 77 | j.AddField("field3", arr); 78 | 79 | arr.Add(1); 80 | arr.Add(2); 81 | arr.Add(3); 82 | 83 | string encodedString = j.print(); 84 | 85 | 86 | NEW! The constructor, Add, and AddField functions now support a nested delegate structure. This is useful if you need to create a nested JSONObject in a single line. For example: 87 | 88 | DoRequest(URL, new JSONObject(delegate(JSONObject request) { 89 | request.AddField("sort", delegate(JSONObject sort) { 90 | sort.AddField("_timestamp", "desc"); 91 | }); 92 | request.AddField("query", new JSONObject(delegate(JSONObject query) { 93 | query.AddField("match_all", JSONObject.obj); 94 | })); 95 | request.AddField("fields", delegate(JSONObject fields) { 96 | fields.Add("_timestamp"); 97 | }); 98 | }).ToString()); 99 | 100 | 101 | == Decoding == 102 | Decoding is much simpler on the input end, and again, what you do with the JSONObject will vary on a per-project basis. One of the more complicated way to extract the data is with a recursive function, as drafted below. Calling the constructor with a properly formatted JSON string will return the root object (or array) containing all of its children, in one neat reference! The data is in a public ArrayList called list, with a matching key list (called keys!) if the root is an Object. If that's confusing, take a glance over the following code and the print() method in the JSONOBject class. If there is an error in the JSON formatting (or if there's an error with my code!) the debug console will read "improper JSON formatting". 103 | 104 | 105 | 106 | string encodedString = "{\"field1\": 0.5,\"field2\": \"sampletext\",\"field3\": [1,2,3]}"; 107 | JSONObject j = new JSONObject(encodedString); 108 | accessData(j); 109 | //access data (and print it) 110 | void accessData(JSONObject obj){ 111 | switch(obj.type){ 112 | case JSONObject.Type.OBJECT: 113 | for(int i = 0; i < obj.list.Count; i++){ 114 | string key = (string)obj.keys[i]; 115 | JSONObject j = (JSONObject)obj.list[i]; 116 | Debug.Log(key); 117 | accessData(j); 118 | } 119 | break; 120 | case JSONObject.Type.ARRAY: 121 | foreach(JSONObject j in obj.list){ 122 | accessData(j); 123 | } 124 | break; 125 | case JSONObject.Type.STRING: 126 | Debug.Log(obj.str); 127 | break; 128 | case JSONObject.Type.NUMBER: 129 | Debug.Log(obj.n); 130 | break; 131 | case JSONObject.Type.BOOL: 132 | Debug.Log(obj.b); 133 | break; 134 | case JSONObject.Type.NULL: 135 | Debug.Log("NULL"); 136 | break; 137 | 138 | } 139 | } 140 | 141 | 142 | NEW! Decoding now also supports a delegate format which will automatically check if a field exists before processing the data, providing an optional parameter for an OnFieldNotFound response. For example: 143 | 144 | new JSONObject(data); 145 | list.GetField("hits", delegate(JSONObject hits) { 146 | hits.GetField("hits", delegate(JSONObject hits2) { 147 | foreach (JSONObject gameSession in hits2.list) { 148 | Debug.Log(gameSession); 149 | } 150 | }); 151 | }, delegate(string name) { //"name" will be equal to the name of the missing field. In this case, "hits" 152 | Debug.LogWarning("no game sessions"); 153 | }); 154 | 155 | 156 | ===Not So New! (O(n)) Random access!=== 157 | I've added a string and int [] index to the class, so you can now retrieve data as such (from above): 158 | 159 | JSONObject arr = obj["field3"]; 160 | Debug.log(arr[2].n); //Should ouptut "3" 161 | 162 | 163 | ---- 164 | 165 | ---Code omitted from readme--- 166 | 167 | =Change Log= 168 | ==v1.4== 169 | Big update! 170 | *Better GC performance. Enough of that garbage! 171 | **Remaining culprits are internal garbage from StringBuilder.Append/AppendFormat, String.Substring, List.Add/GrowIfNeeded, Single.ToString 172 | *Added asynchronous Stringify function for serializing large amounts of data at runtime without frame drops 173 | *Added Baked type 174 | *Added MaxDepth to parsing function 175 | *Various cleanup refactors recommended by ReSharper 176 | 177 | ==v1.3.2== 178 | *Added support for NaN 179 | *Added strict mode to fail on purpose for improper formatting. Right now this just means that if the parse string doesn't start with [ or {, it will print a warning and return a null JO. 180 | *Changed infinity and NaN implementation to use float and double instead of Mathf 181 | *Handles empty objects/arrays better 182 | *Added a flag to print and ToString to turn on/off pretty print. The define on top is now an override to system-wide disable 183 | ==Earlier Versions== 184 | I'll fill these in later... 185 | [[Category:C Sharp]] 186 | [[Category:Scripts]] 187 | [[Category:Utility]] 188 | [[Category:JSON]] 189 | -------------------------------------------------------------------------------- /unity/bcx/Assets/JSON/readme.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 80b692916bec1664098283aa4425e4d8 3 | -------------------------------------------------------------------------------- /unity/bcx/Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 787d9c75702ec4683a8d3b5c25296548 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1aabd29b7917145f1ad49f5017d123f9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /unity/bcx/Assets/Plugins/Android/mainTemplate.gradle: -------------------------------------------------------------------------------- 1 | // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN 2 | buildscript { 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.2' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | google() 16 | jcenter() 17 | flatDir { 18 | dirs 'libs' 19 | } 20 | } 21 | } 22 | 23 | apply plugin: 'com.android.application' 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) 27 | 28 | // implenment websocket 29 | implementation 'com.neovisionaries:nv-websocket-client:1.30' 30 | // implenment bitcoinj 31 | implementation 'org.bitcoinj:bitcoinj-core:0.14.7' 32 | implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' 33 | implementation group: "org.tukaani", name: "xz", version: "1.6" 34 | implementation 'com.squareup.okhttp3:okhttp:3.12.1' 35 | // spongycastle 36 | implementation 'com.madgag.spongycastle:core:1.58.0.0' 37 | implementation 'com.madgag.spongycastle:prov:1.58.0.0' 38 | implementation 'com.madgag.spongycastle:pkix:1.54.0.0' 39 | implementation 'com.madgag.spongycastle:pg:1.54.0.0' 40 | // fasterxml 41 | implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.7' 42 | 43 | **DEPS** 44 | 45 | } 46 | 47 | android { 48 | compileSdkVersion **APIVERSION** 49 | buildToolsVersion '**BUILDTOOLS**' 50 | 51 | defaultConfig { 52 | minSdkVersion **MINSDKVERSION** 53 | targetSdkVersion **TARGETSDKVERSION** 54 | applicationId '**APPLICATIONID**' 55 | ndk { 56 | abiFilters **ABIFILTERS** 57 | } 58 | versionCode **VERSIONCODE** 59 | versionName '**VERSIONNAME**' 60 | } 61 | 62 | lintOptions { 63 | abortOnError false 64 | } 65 | 66 | aaptOptions { 67 | noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS** 68 | } 69 | 70 | **SIGN** 71 | buildTypes { 72 | debug { 73 | minifyEnabled **MINIFY_DEBUG** 74 | useProguard **PROGUARD_DEBUG** 75 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD** 76 | jniDebuggable true 77 | } 78 | release { 79 | minifyEnabled **MINIFY_RELEASE** 80 | useProguard **PROGUARD_RELEASE** 81 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD** 82 | **SIGNCONFIG** 83 | } 84 | } 85 | **PACKAGING_OPTIONS** 86 | } 87 | 88 | 89 | **SOURCE_BUILD_SETUP** -------------------------------------------------------------------------------- /unity/bcx/Assets/Plugins/Android/mainTemplate.gradle.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00a07caa237394ab3800185f87c73f9c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /unity/bcx/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_SpritePackerMode: 0 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} 40 | - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0} 41 | m_PreloadedShaders: [] 42 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 43 | type: 0} 44 | m_CustomRenderPipeline: {fileID: 0} 45 | m_TransparencySortMode: 0 46 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 47 | m_DefaultRenderingPath: 1 48 | m_DefaultMobileRenderingPath: 1 49 | m_TierSettings: [] 50 | m_LightmapStripping: 0 51 | m_FogStripping: 0 52 | m_InstancingStripping: 0 53 | m_LightmapKeepPlain: 1 54 | m_LightmapKeepDirCombined: 1 55 | m_LightmapKeepDynamicPlain: 1 56 | m_LightmapKeepDynamicDirCombined: 1 57 | m_LightmapKeepShadowMask: 1 58 | m_LightmapKeepSubtractive: 1 59 | m_FogKeepLinear: 1 60 | m_FogKeepExp: 1 61 | m_FogKeepExp2: 1 62 | m_AlbedoSwatchInfos: [] 63 | m_LightsUseLinearIntensity: 0 64 | m_LightsUseColorTemperature: 0 65 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AutoSyncTransforms: 1 28 | m_AlwaysShowColliders: 0 29 | m_ShowColliderSleep: 1 30 | m_ShowColliderContacts: 0 31 | m_ShowColliderAABB: 0 32 | m_ContactArrowScale: 0.2 33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 38 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.1.0f2 2 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 4 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 4 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 1 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 1 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 4 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 2 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 1 108 | antiAliasing: 2 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 1 112 | billboardsFaceCameraPosition: 1 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 4 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 2 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 40 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 1 136 | antiAliasing: 4 137 | softParticles: 1 138 | softVegetation: 1 139 | realtimeReflectionProbes: 1 140 | billboardsFaceCameraPosition: 1 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 4 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 1 164 | antiAliasing: 4 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 4 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSP2: 2 183 | Standalone: 5 184 | Tizen: 2 185 | WebGL: 3 186 | WiiU: 5 187 | Windows Store Apps: 5 188 | XboxOne: 5 189 | iPhone: 2 190 | tvOS: 2 191 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - PostProcessing 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.0167 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /unity/bcx/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate 14 | m_Enabled: 0 15 | m_CaptureEditorExceptions: 1 16 | UnityPurchasingSettings: 17 | m_Enabled: 0 18 | m_TestMode: 0 19 | UnityAnalyticsSettings: 20 | m_Enabled: 1 21 | m_InitializeOnStartup: 1 22 | m_TestMode: 0 23 | m_TestEventUrl: 24 | m_TestConfigUrl: 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | --------------------------------------------------------------------------------