yasirkula / unityionicintegration Goto Github PK
View Code? Open in Web Editor NEWA guide to integrating Unity 3D content into an Ionic app and sending messages between them (for Android & iOS)(tested with Vuforia plugin)
A guide to integrating Unity 3D content into an Ionic app and sending messages between them (for Android & iOS)(tested with Vuforia plugin)
Hello I have an error while running the application under android when I call the function to launch unity, I have the following error:
06-29 16:04:47.106 18699-18699/fr.xx.xx E/ActivityThread: Activity fr.xx.xx.MainActivity has leaked IntentReceiver org.apache.cordova.plugin.CordovaUnityLauncher$UnityToIonicBroadcastReceiver@ec2200e that was originally registered here. Are you missing a call to unregisterReceiver()?
Compilation is not a problem.
Thank you for your help
Hi there,
First of all thanks to all who contributed to this, a really helpful plugin/ feature for a Cordova app.
My only question is, is there any way of stopping the Unity side from running in the background?
Application.Quit() is exiting the entire process ID of the app and I would just like to stop the Unity service from running in the background.
Thanks,
George
Hi,
I'm trying to follow your tutorial to see how to link a Cordova project with Unity on iOS (without Vuforia for now) and I got linking errors that prevent me to compile:
Undefined symbols for architecture armv7:
"_UnitySetGraphicsDevice", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
Do I need to add a framework ? Because I couldn't find their definition anywhere.
Hi, this is not an issue, it's just to let you and the users know that this also works with EasyAR and VoidAR.
I already managed to make this work perfectly with those SDK's.
Here's how I did it:
For Android:
*All the unity steps are the same, then, after building the project for gradle, you just have to add the following line in the dependencies of the build.gradle file of the Ionic project (platforms/android/build.gradle):
For EasyAR:
compile fileTree(dir: '/<path to your Unity exported project>/libs', include: 'EasyAR.jar')
For VoidAR:
or compile fileTree(dir: '/<path to your Unity exported project>/libs', include: 'VoidAR.jar')
Remember to change the path for your relative or absolute path.
Because if you don't reference the .jar file there, the module will close because it can't find the .jar classes.
For IOS:
The steps are literally the same, but when you open the AR view, you will probably get a black screen. If that's happening, do the following:
extern "C" void ezarUnitySetGraphicsDevice(void* device, int deviceType, int eventType);
extern "C" void ezarUnityRenderEvent(int marker);
Then, in that same class, on the shouldAttachRenderDelegate() method, add the following inside the if:
UnityRegisterRenderingPlugin(&ezarUnitySetGraphicsDevice, &ezarUnityRenderEvent);
I hope it helps.
I'm getting the following errors after following all the instructions:
Classes/AppDelegate.mm:45:13: Use of undeclared identifier 'UnityRegisterRenderingPlugin'
Classes/AppDelegate.mm:50:12: Use of undeclared identifier 'UnityGetMainWindow'
Classes/AppDelegate.mm:109:9: Use of undeclared identifier 'UnitySendMessage'
Classes/AppDelegate.mm:123:9: Use of undeclared identifier 'UnitySendMessage'
I can see these methods are in the file UnityInterface.h so I added an import line to the file but then I get linking errors.
Undefined symbols for architecture arm64:
"_UnityGetMainWindow", referenced from:
-[AppDelegate unityWindow] in AppDelegate.o
"OBJC_CLASS$_VuforiaRenderDelegate", referenced from:
objc-class-ref in AppDelegate.o
"OBJC_CLASS$_UnityAppController", referenced from:
objc-class-ref in AppDelegate.o
"_UnitySendMessage", referenced from:
-[AppDelegate sendMessageToUnity:] in AppDelegate.o
-[AppDelegate sendMessageToUnity:parameter:] in AppDelegate.o
"_VuforiaRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRegisterRenderingPlugin", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas? Any help is appreciated.
After integration, when running on iOS, the app opens and the Ionic side is working. When I tap on the button that starts Unity (using the openUnity() method) I'm getting the following error:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x30)
Here are screenshots of exactly what's happening:
https://pasteboard.co/H39PlhX.png
https://pasteboard.co/H39YwmR.png
Using Unity 2017.3.0f3, Ionic 3.19.0, Cordova 7.1.0. In the current scenario, the Unity project only contains a blank scene (with the integration scripts and files). We're also not using Vuforia for now. The Ionic project is a bare minimum too (only one button calling openUnity(), and the plugin).
We have tried building several times on different Macs and different devices. I'm pretty sure we're not missing any steps.
Any ideas?
Appreciate the help!
Ian
Ps. Just to be thorough, here is an ionic info dump:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.6
Cordova Platforms : ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
ios-deploy : 1.9.2
Node : v8.9.1
npm : 5.5.1
OS : macOS Sierra
Xcode : Xcode 9.2 Build version 9C40b
Hello, I have I Ionic project that works well, builds an run. The project uses one signal plugin for notifications.
After I have installer the unityIonicIntegration plugin it stops build and throws this error : 'OneSignal/OneSignal.h' file not found
When we export our project for iOS there isn't a Data\Raw\QCAR folder. Instead there is a Data\Raw\Vuforia folder. Is there something that has to be done to get the QCAR folder?
Hi, I'm trying to integrate your plugin with a plain cordova app. I successfully managed to start the Unity Activity, but once finish
is called, the main cordova activity is restarted. Am I missing something?
Thank you.
I also do not get the onActivityResult
callback.
Hi @yasirkula ,
I followed each step of your very precise and thorough tutorial for iOS, and I got absolutely no problem.
(just a parenthesis : this time, on iOS, no dark Unity screen unlike android ;-) )
My Unity project recognises a photo and play a video overlay (with music). I hear the music but the video frame remains black.
Someone has the same problem on StackOverflow, and they advise to disable multi-threading, but my Unity version is more recent, and I can't find this setting.
https://stackoverflow.com/questions/36563405/vuforia-video-playback-video-is-black?rq=1
It seems problem isn't due to your process, but I dare to ask : did you encounter the same problem ? :)
Thank you very much in advance.
EDIT :
Oh, it works on an iPhone SE with iOS 10, but not with an iPodTouch on iOS 9.
Hi guys,
I wonder if you guys have tried Mapbox in Unity with this plugin yet.
I encountered this error.
I found out I need to add this $(UNITY_IOS_EXPORTED_PATH)/Libraries/Mapbox/Core/Plugins/iOS/MapboxMobileEvents/include/
to Search Header Path
and libz.tbz
to Linked Framework and Libraries
and then I stuck with this error.
I appreciate if someone can help me on this.
Hello,
I am trying to achieve the integration of my ionic2 project with my unity project. I have a unity project which contains a 3d model. Inside my ionic application, I want to load that 3D model on click of a button.
First of all, I had a few basic questions:
1) Should I use my entire unity project for this or Should I use the exported WebGL of my project?
2) Should I keep that unity project inside my ionic application directory or should I keep both projects separate?
I tried both the options i.e using the entire project & using the WebGL
I followed all the steps given in the documentation (I am not using android studio for this integration)
Installed the plugin & added the code in my typescript file
I kept the IonicComms.cs file in the assets folder of my unity project
I edited the GradleBuilder.js file to put the following content in my settings.gradle file
include ":UnityProject"
project(":UnityProject").projectDir = new File("complete path to my unity project")
I edited build.gradle file where I tried both options:
compile project(':UnityProject')
or
implementation(project(path: "UnityProject"))
(because compile is deprecated)
& used
apply plugin: 'com.android.library'
I deleted unity-classes.jar
I deleted activity tag from android manifest file as well.
I am getting an error in the build process
Could not determine the dependencies of task ':compileDebugJavaWithJavac'.
Could not resolve all task dependencies for configuration ':debugCompileClasspath'
Could not resolve project :UnityProject.
Required by: project :
Unable to find a matching configuration of project :UnityProject: None of the consumable configurations have attributes.
I tried googling this error as well but it was of no help. Please help me with those 3 questions.
Hi everyone,
I'm posting this here just to let other users know of some lessons learnt / changes we've experienced using Vuforia 7 and the new Unity.
Unity Side Setup
iOS Side Setup
Android setup
Kind regards,
Ian
Could you restructure the repo so that you could add the plugin like this?
ionic cordova plugin add https://github.com/kevin-smets/UnityIonicIntegration.git#1.0.0
This is just a fork where I added a package.json and moved some resources around to make it installable remotely.
After following the steps I am getting the following error from Classes\AppDelegate.h:
'UnityAppController.h' file not found
I have completed and re-verified the following steps:
--In Configurations of your project, set all the configurations as unityconfig
--In Build Settings, set the value of UNITY_IOS_EXPORTED_PATH to the path of your Unity iOS build folder (do this for PROJECT and the TARGETS)
--In Build Settings, select Prefix Header and press Delete to revert its value back to the default value (in case it is overridden)(do this for PROJECT and the TARGETS)
Any ideas if there is something else that could be missing?
2018-10-26 01:36:59.799248+1000 PurposeUniversity[752:156426] showUnityWindow
-> applicationDidFinishLaunching()
PurposeUniversity was compiled with optimization - stepping may behave oddly; variables may not be available.
I followed all instructions and xcode projects runs without any issues.
But when I click a button to show unity player it shows above error and stops working.
Original project is using Vuforia and faced same error.
So I created new empty unity project but got same error.
Unity version : 2018.2.1f1
How can I solve this issue?
Thanks.
Hi!
I am currently try to make unity vuforia and ionic work and I follow every single step, but I always get 'il2cpp-config.h'
file not found error and I cant figure out the problem.
I go through the folders and this file is in the libil2cpp folder but I deleted this folder as the tutorial said.
Hello, I encounter a compilation problem under android studio 3.1.2, when I delete the unity-classes.jar file in the libs folder of the android project, I have 7 compilation errors:
error: can not find UnityPlayer class symbol
error: can not find symbol class UnityPlayerActivity
error or method not applicable or a method from a supertype
error: registerReceiver (IonicToUnityBroadcastReceiver, IntentFilter)
error or method not applicable or a method from a supertype
error: can not find symbol variable super
error: can not find symbol method setResult (Int, Intent)
I am trying to integrate mapbox unity project with ionic ios project.I followed all the iOS steps and ended up with this lexical or preprocessor issue.
Unity version 2018.2.3f1
mapbox https://www.mapbox.com
Hi there,
I am using Unity 2017.3.0f3 with Vuforia 7.0.36. I now get this error
Error:Failed to resolve: :VuforiaWrapper: when syncing.
I suspect it has to do with this in build.gradle for the UnityProject
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'VuforiaWrapper', ext:'aar')
}
I used to build with Unity 2017.2.0b10, and the VuforiaWrapper dependency was not there. When I remove that dependency the project builds, but of course Vuforia does not work.
Any ideas? The error only occurs when integrating, meaning that I can build the Unity Grade project on its own without problems.
Much appreciated!
Ian
Ps. Seems like this individual has a similar problem: https://developer.vuforia.com/forum/unity/error-import-unity-project-android-studio
Hello,
I'm building a cross platform app using Ionic + Unity with Vuforia, and its currently working smoothly with Android.
I've been struggling with making it work properly in iOS. As soon as I launch unity, the splash screen shows up and the app crashes with the following error:
Uncaught exception: NSInvalidArgumentException: -[NSNull UTF8String]: unrecognized selector sent to instance 0x1b2da0650'
It also points to the following line on Other sources/main.mm
Full log:
https://pastebin.com/raw/jHfSXZ2s
I've searched around and no one seems to be having this issue.
Any clue? my main.mm seems fine.
Thanks.
I just couldn't seem to figure this out. Did everything on the list, but i'm getting this error in my build:
After some searching around, I ended up adding the unity-classes.jar
to the main android project as a library, but then I receive this error, which seems like its trying to add it in twice. I've tried different combinations of where to implement this, but I keep getting one error or the other:
The Unity build works by itself without the plugin, so I'm not sure what is going wrong here.
Any help would be much appreciated!
When I run the command:
ionic cordova plugin add https://github.com/yasirkula/UnityIonicIntegration.git ,
I get this error:
(node:4992) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to fetch plugin https://github.com/yasirkula/UnityIonicIntegration.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: cmd: Command failed with exit code 1 Error output:
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: Cloning into 'C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0'...
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: git-upload-pack 'C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645': git-upload-pack: command not found
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: fatal: Could not read from remote repository.
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0:
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: Please make sure you have the correct access rights
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0: and the repository exists.
npm ERR! git clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0:
npm ERR! Windows_NT 10.0.17134
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "https://github.com/yasirkula/UnityIonicIntegration.git" "--production" "--save"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! code 128
npm ERR! Command failed: git -c core.longpaths=true clone C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645 C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0
npm ERR! Cloning into 'C:\Users\Matheus\AppData\Local\Temp\npm-5728-9761bbd4\git-cache-0cccc512\672026213463920fbdcf49ec2bac6e56fb19b1c0'...
npm ERR! git-upload-pack 'C:\Users\Matheus\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-yasirkula-UnityIonicIntegration-git-ef48a645': git-upload-pack: command not found
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! D:\Desenvolvimento\workspace\anime-buzz-mobile\animebuzz-mobile\npm-debug.log
Hi everyone!
This comment is related to #16
When you build your app in Xcode to iOS 11.3 and you start unity the camera shows black screen. The UI and everything else works fine but everything is black. The problem is currently you can't build your Vuforia(or any Unity app but I am not tested it) with Xcode 11.3.
The solution is really weird but working. These are the steps:
-First download Xcode 9.2
-Extract it and rename to "Xcode 9.2" and put it into the Application folder (important note: Do not delete or replace Xcode 9.3 because you still need it)
-After you install you have to find Xcode 9.3 -> right click -> Show Package Contents -> Contents -> Developer -> Platforms -> iPhoneOS.platform -> DeviceSupport -> copy 11.3 folder and paste it the same place in Xcode 9.2
-Open the project in Xcode 9.2 and Build
-And it will be working again
Kind regards,
Máté
Hello,
thank you for this tutorial. Followed all the steps, but in the main.mm file i have the following
errors: (screen the image bellow)
This is the file content:
`#include "RegisterMonoModules.h"
#include "RegisterFeatures.h"
#include
// Hack to work around iOS SDK 4.3 linker problem
// we need at least one __TEXT, __const section entry in main application .o files
// to get this section emitted at right time and so avoid LC_ENCRYPTION_INFO size miscalculation
static const int constsection = 0;
void UnityInitTrampoline();
// WARNING: this MUST be c decl (NSString ctor will be called after +load, so we cant really change its value)
const char* AppControllerClassName = "AppDelegate";
int main(int argc, char* argv[])
{
@autoreleasepool
{
UnityInitTrampoline();
UnityParseCommandLine(argc, argv);
RegisterMonoModules();
NSLog(@"-> registered mono modules %p\n", &constsection);
RegisterFeatures();
// iOS terminates open sockets when an application enters background mode.
// The next write to any of such socket causes SIGPIPE signal being raised,
// even if the request has been done from scripting side. This disables the
// signal and allows Mono to throw a proper C# exception.
std::signal(SIGPIPE, SIG_IGN);
UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:AppControllerClassName]);
}
return 0;
}
#if TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR
#include <pthread.h>
extern "C" int pthread_cond_init$UNIX2003(pthread_cond_t *cond, const pthread_condattr_t *attr)
{ return pthread_cond_init(cond, attr); }
extern "C" int pthread_cond_destroy$UNIX2003(pthread_cond_t *cond)
{ return pthread_cond_destroy(cond); }
extern "C" int pthread_cond_wait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex)
{ return pthread_cond_wait(cond, mutex); }
extern "C" int pthread_cond_timedwait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime)
{ return pthread_cond_timedwait(cond, mutex, abstime); }
#endif // TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR
`
Simple to reproduce. I created a blank project with a button to open my unity app (android). Worked no problems.
Then added ionic storage to my project https://ionicframework.com/docs/storage/ :
ionic cordova plugin add cordova-sqlite-storage
npm install --save @ionic/storage
Rebuilt my app... then when trying to open unity got an error message "Failure to initialize Your hardware does not support this application, sorry" (all on my physical device, s7 edge)
I think the root of the problem is that storage adds a bunch of folders under "android>jnilibs" folder
After following steps outlined in readme, I am having issues building to an iOS device. Xcode provides the following error:
Any ideas?
Edit:
I see some references in the error log to "MetalRenderData"... I have double checked and my Unity project settings have auto graphics api unchecked and OpenGLES2 is the only enabled option
Hi,
I worked on integrating Unity into a Cordova app (only on Android for now) and I found a better way to avoid error while building with Cordova a second time.
Actually, what makes the error is the file Settings.Gradle is auto-generated during the building so it overrides the line
project(':UnityProject').projectDir = new File('C:\absolute path\to your\unity export folder')
Basically you'll need to add this line each time after you build Cordova. But there is another way, you can add this line automatically. To do so, you'll need to
fr.writeFileSync(path.join(this.root, 'settings.gradle'), '//GENERATED FILE - DO NOT EDIT\n' + 'include ":"\n' + settingsGradlePaths.join('') + 'project(":UnityProject").projectDir = new File("C:\\absolute path\\to your\\unity export folder")');
I did this with Cordova but I think it would be no different with Ionic, and thanks to that you don't need to remove then add android platform, which requires to re-import Unity and redo all the code on AS each time.
Hope this will be useful for you !
I follow all steps of UnityIonicIntegration plugin, i facing above error in xCode,
how can i do to solve this error from xCode?
Hi,
I followed the tutorial with partial luck. The app builds and launch on iPhone X but when i press the button in Cordova part to launch Unity the app just closes. No error or something.
Unity app is basic ARKit app to show model on table.
I've added ARKit, min SDK is 11.4.
What else can i send you so you could help me?
EDIT
i moved forward with:
#15
but now I get:
http://prntscr.com/ku5h7f
Hello,
First of all, thanks for your ressources and your explanations. I followed it for an Android project, and everything related to Android part works well (I'm an Android native dev, it may helps... :) but I'm Ionic and Unity newbie).
My sample app is pretty simple : I put a button on the home page, and when I click on it, it calls openUnity().
But when I click the button, I see in the Android Logcat :
D/SystemWebChromeClient: ng:///AppModule/HomePage.ngfactory.js: Line 115 : ERROR
06-01 01:23:13.830 17298-17298/io.ionic.starter I/chromium: [INFO:CONSOLE(115)] "ERROR", source: ng:///AppModule/HomePage.ngfactory.js (115)
06-01 01:23:13.833 17298-17298/io.ionic.starter D/SystemWebChromeClient: ng:///AppModule/HomePage.ngfactory.js: Line 115 : ERROR CONTEXT
06-01 01:23:13.833 17298-17298/io.ionic.starter I/chromium: [INFO:CONSOLE(115)] "ERROR CONTEXT", source: ng:///AppModule/HomePage.ngfactory.js (115)
06-01 01:23:13.843 17298-17298/io.ionic.starter W/cr_Ime: updateState: type [0->0], flags [0], show [false],
...and nothing happens. The app doesn't crash, but nothing happens. However, the Unity project alone works well : I already built it and deployed as a standalone app, and it works fine.
As I'm a newbie in Ionic, I may be missing something, but I don't understand clearly what. Your sample code makes me think I wouldn't have to call the Unity activity with the Ionic NavController navCtrl.push() method like we should do in a normal "launch new Activity" context.
However, if a change my Ionic button behaviour, and make it call a dummy function (displaying a simple alert dialog with a dummy message), it works. (hopefully !! ^^ if not I'd better worry)
Could you please give more info/context/details about calling this.unityARCaller.launchAR(...) ?
Thanks.
Here is my very simple home.ts file :
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
unityARCaller: any;
constructor(public navCtrl: NavController) {
}
openUnity() {
// it is possible to send a string message to Unity-side (optional)
this.unityARCaller.launchAR("my message for Unity-side", this.uSuccessCallback, this.uFailedCallback );
}
uSuccessCallback = (param) => {
// param:String is the (optional) message received from Unity-side
// alert( param );
};
uFailedCallback = (error) => {
// should ignore this callback
};
openAR(){
// alert("Launch AR")
this.openUnity();
}
}
And my (as simple as previous one) home.html file :
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<button ion-button (click)="openAR()">Start AR</button>
</ion-content>
I'm running Ionic 3.0.0, Cordova 7.0.1
Thank you for this project. Your are a life saver.
I followed the documentation for android and worked great on Ionic 3.9.2 (still need to test with IoS). The only thinkg missing is that the plugin won't add without a "package.json" in the plugin folder. I followed https://stackoverflow.com/a/44455103 to generate a simple package.json and it worked. Also there are some minor changes in the calls of ionic, instead of "ionic platform add" it is now "ionic cordova platform add".
I try to follow instruction for iOS. After I build project I recieve this error.
Undefined symbols for architecture arm64:
"_UnitySetGraphicsDevice", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Hello,
I’m currently trying to build an empty unity project and a blank Ionic project on ios following your guide.
I have followed every step multiple times with different projects from scratch.
I am practically a beginner in all the ionic/web/html side for the record, so maybe i’m missing something obvious.
The ionic project works on its own when built and run from xcode or CLI.
The unity project works on its own as well.
After following the iOS steps, though, various errors start coming but seem all related to il2cpp and mscorlib.
Software used :
Unity 2017.4 and 2018.3
Ionic 4 and 3
Angular : Latest
extern "C" IL2CPP_METHOD_ATTR int32_t MonoCMethod_get_core_clr_security_level_m1431438660 (MonoCMethod_t3191134373 * __this, const RuntimeMethod* method)
{
typedef int32_t (*MonoCMethod_get_core_clr_security_level_m1431438660_ftn) (MonoCMethod_t3191134373 *);
using namespace il2cpp::icalls;
return ((MonoCMethod_get_core_clr_security_level_m1431438660_ftn)mscorlib::System::Reflection::MonoCMethod::get_core_clr_security_level) (__this);
}
mscorlib::System::Reflection::MonoCMethod::get_core_clr_security_level
No member named 'get_core_clr_security_level' in 'il2cpp::icalls::mscorlib::System::Reflection::MonoCMethod'
extern "C" IL2CPP_METHOD_ATTR void CustomAttributeData_ResolveArgumentsInternal_m4232068489 (RuntimeObject * __this /* static, unused */, ConstructorInfo_t5769829 * ___ctor0, Assembly_t * ___assembly1, intptr_t ___data2, uint32_t ___data_length3, ObjectU5BU5D_t2843939325** ___ctorArgs4, ObjectU5BU5D_t2843939325** ___namedArgs5, const RuntimeMethod* method)
{
typedef void (*CustomAttributeData_ResolveArgumentsInternal_m4232068489_ftn) (ConstructorInfo_t5769829 *, Assembly_t *, intptr_t, uint32_t, ObjectU5BU5D_t2843939325**, ObjectU5BU5D_t2843939325**);
using namespace il2cpp::icalls;
((CustomAttributeData_ResolveArgumentsInternal_m4232068489_ftn)mscorlib::System::Reflection::CustomAttributeData::ResolveArgumentsInternal) (___ctor0, ___assembly1, ___data2, ___data_length3, ___ctorArgs4, ___namedArgs5);
}
mscorlib::System::Reflection::CustomAttributeData::ResolveArgumentsInternal
No member named 'CustomAttributeData' in namespace 'il2cpp::icalls::mscorlib::System::Reflection'; did you mean 'CustomAttributesCache'?
Replace 'mscorlib::System::Reflection::CustomAttributeData' with 'CustomAttributesCache'
No member named 'ResolveArgumentsInternal' in 'CustomAttributesCache'
and 6 other similar errors, not sure if it's useful to paste them.
If you have any question or suggestion I would be extremely thankful !
Hi there,
We have a Vuforia marker with a video that plays when the marker is scanned. The video is included in the Unity project. The video just appears black on Android devices and eventually crashes the unity part of the app. We've got other markers that display 3D assets too and they work perfectly fine on Android.
If we only run the Unity project separately the video works on Android, so this only happens when the project is integrated.
Everything is fine on iOS.
We've tried removing the multi-threaded rendering and transcoding the videos (and the override for android option). We also tried vp8 and h.264 codecs (specified in Unity).
We've been battling with this for 2 solid days and I'm out of ideas.
Do you perhaps have a clue of what could be the problem?
Kind regards,
Ian
I use windows powershell and build android.But it is wrong. How do I do?
PS D:\Projects\MyApp> ionic cordova build android
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_coo6rr94g5y9x4vy26v2tw0nc.run(D:\Projects\MyApp\platforms\android\app\build.gradle:147)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
FAILURE: Build failed with an exception.
Where:
Build file 'D:\Projects\MyApp\platforms\android\app\build.gradle' line: 268
What went wrong:
A problem occurred evaluating project ':app'.
Project with path ':UnityProject' could not be found in project ':app'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
(node:1332) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
This is my settings.gradle
include ":"
include ":CordovaLib"
include ":app"
include ':UnityProject'
project(':UnityProject').projectDir = new File('D:\Projects\MyApp\platforms\android\ARSystem')
Hi, I followed the steps for a v1 ionic app, and every time I click the button to open the unity part, the screen became black for 1 second and then goes back to the ionic view.
After starting the app I get the following erros:
5.820 24867-24938/io.ionic.starter E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
10-02 07:48:45.920 24867-24938/io.ionic.starter E/chromium: [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
10-02 07:48:46.390 24867-24938/io.ionic.starter E/chromium: [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
10-02 07:48:47.690 24867-24937/io.ionic.starter E/chromium: [ERROR:budget_service.cc(145)] Unable to connect to the Mojo BudgetService.
10-02 07:48:47.930 24867-24938/io.ionic.starter E/chromium: [ERROR:texture_manager.cc(3410)] [.RenderWorker-0x5579f8bfc0]GL ERROR :GL_INVALID_ENUM : glTexImage2D: <- error from previous GL command
and when I click the button to launch unity, I get the following erros:
10-02 07:50:01.390 24867-24938/io.ionic.starter E/chromium: [ERROR:texture_manager.cc(3410)] [.RenderWorker-0x5579f8bfc0]GL ERROR :GL_INVALID_ENUM : glTexImage2D: <- error from previous GL command
10-02 07:50:01.450 24867-24938/io.ionic.starter E/chromium: [ERROR:gles2_cmd_decoder.cc(8216)] [.RenderWorker-0x5579f8bfc0.GpuRasterization]GL ERROR :GL_INVALID_ENUM : glFramebufferTexture2D: <- error from previous GL command
I thought it was due to my unity export opengl, but I tried everything (Opengl2, Opengl3, Autographics Enabled) and I still getting the same error and don't see the unity app.
Hey all! When I try to build on a clean project after adding the ionic plugin from the tutorial, this is the error log I get. Not sure what I can do to solve it. Do I need to be on a older gradle version?
Ionic:
ionic (Ionic CLI) : 4.1.1 (/Users/ivan.mayes/.npm_modules/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0
Cordova Plugins : no whitelisted plugins (0 plugins total)
System:
Android SDK Tools : 26.1.1 (/Users/ivan.mayes/Library/Android/sdk)
NodeJS : v10.6.0 (/usr/local/bin/node)
npm : 6.1.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
BUILD FAILED in 24s
38 actionable tasks: 38 executed
(node:20377) UnhandledPromiseRejectionWarning: Error: /Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:13: error: package com.unity3d.player does not exist
import com.unity3d.player.UnityPlayer;
^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:14: error: package com.unity3d.player does not exist
import com.unity3d.player.UnityPlayerActivity;
^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:16: error: cannot find symbol
public class UnityPlayerExtendedActivity extends UnityPlayerActivity
^
symbol: class UnityPlayerActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:24: error: cannot find symbol
UnityPlayer.UnitySendMessage("IonicComms", intent.getStringExtra( "func" ), intent.getStringExtra( "param" ) );
^
symbol: variable UnityPlayer
location: class IonicToUnityBroadcastReceiver
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:34: error: method does not override or implement a method from a supertype
@Override protected void onCreate (Bundle savedInstanceState)
^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:36: error: cannot find symbol
Intent intent = getIntent();
^
symbol: method getIntent()
location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:42: error: cannot find symbol
registerReceiver(broadcastReceiver, new IntentFilter( CordovaUnityLauncher.IONIC2UNITY_SEND_MESSAGE_BROADCAST ) );
^
symbol: method registerReceiver(IonicToUnityBroadcastReceiver,IntentFilter)
location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:43: error: cannot find symbol
super.onCreate(savedInstanceState);
^
symbol: variable super
location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:46: error: method does not override or implement a method from a supertype
@Override protected void onDestroy ()
^
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:48: error: cannot find symbol
unregisterReceiver( broadcastReceiver );
^
symbol: method unregisterReceiver(IonicToUnityBroadcastReceiver)
location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:49: error: cannot find symbol
super.onDestroy();
^
symbol: variable super
location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:59: error: cannot find symbol
sendBroadcast( ionicMessage );
^
symbol: method sendBroadcast(Intent)
location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:75: error: cannot find symbol
setResult(Activity.RESULT_OK, resultIntent);
^
symbol: method setResult(int,Intent)
location: class UnityPlayerExtendedActivity
/Users/ivan.mayes/Projects/_tests/ionic-unity-test/platforms/android/app/src/main/java/com/unitycaller/ionic/UnityPlayerExtendedActivity.java:77: error: cannot find symbol
finish();
^
symbol: method finish()
location: class UnityPlayerExtendedActivity
14 errors
FAILURE: Build failed with an exception.
Hi.
I am working with a Unity 2017.3 project and I have problems to solve dependences on the Unity's build.gradle because I must to compile a gvr.aar file and unitygvr.aar file on the libs folder, this files are created with my Unity project.
The Android Studio throws "Failed to resolve: gvr" and "Failed to resolve: unitygvr"
This is my Unity build.gradle fragment:
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'gvr', ext:'aar')
compile(name: 'unitygvr', ext:'aar')
}
How can I fix that?
Thanks
I'm getting the following errors after following all the instructions:
Classes/AppDelegate.mm:45:13: Use of undeclared identifier 'UnityRegisterRenderingPlugin'
Classes/AppDelegate.mm:50:12: Use of undeclared identifier 'UnityGetMainWindow'
Classes/AppDelegate.mm:109:9: Use of undeclared identifier 'UnitySendMessage'
Classes/AppDelegate.mm:123:9: Use of undeclared identifier 'UnitySendMessage'
I can see these methods are in the file UnityInterface.h so I added an import line to the file but then I get linking errors.
Undefined symbols for architecture arm64:
"_UnityGetMainWindow", referenced from:
-[AppDelegate unityWindow] in AppDelegate.o
"OBJC_CLASS$_VuforiaRenderDelegate", referenced from:
objc-class-ref in AppDelegate.o
"OBJC_CLASS$_UnityAppController", referenced from:
objc-class-ref in AppDelegate.o
"_UnitySendMessage", referenced from:
-[AppDelegate sendMessageToUnity:] in AppDelegate.o
-[AppDelegate sendMessageToUnity:parameter:] in AppDelegate.o
"_VuforiaRenderEvent", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
"_UnityRegisterRenderingPlugin", referenced from:
-[AppDelegate shouldAttachRenderDelegate] in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas? Any help is appreciated.
Followed the instructions in the Readme. When I try to build to device I get the following error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Not really sure how to go about fixing this. Any ideas?
What versions of Unity and Vuforia are supported? I'm asking because I tested this out initially with a Unity 2018.1.5 and Vuforia 7.1.35 and everything worked (I used xCode 8.3 to do most of the project configurations, and then opened the configured project in xCode 9.4 so that I could build for iOS 11.4, and everything worked beautifully).
However, I realized the Unity project I need to use in my app does not work on newer unity versions, so I rebuilt it using Unity 2017.2.2 and Vuforia 6.5.25. Now I'm running into the following error:
clang: error: no such file or directory $UNITY_BUILD_FOLDER/Classes/Native/Bulk_UnityEngine.UI_2.cpp
and I see that the file is not included in the build directory from older Unity version. I've been trying to see if I can use the libil2cpp folder from the 2018.1.5 version build (or at least to copy over some of the include files), but I'm sort of going in circles because then other files are missing or renamed.
I will continue trying to patch this together, and if no luck, I will attempt a fresh build from the very beginning.
In the meantime, would be helpful to know:
Are Unity 2017.2.2 builds are even supported?
If they are supported, what could trying to include the "Bulk_UnityEngine.UI_2.cpp" file?
BTW, this repo is AWESOME, and its obvious you put a lot of work into it and are very much on top of responding to issues. Thanks so much for that. It's really amazing of you.
I have followed each and every steps of UnityIonicIntegration to complete integration of unity to ionic .
my code in .m file
- (void)sendMessageToIonic:(NSString*)message
{
// [self setTitleOfButtonNamed:buttonOne withTitle:btnOneTitle];
[self.ionicComms receivedMessageFromUnity:message];
}
I have also tried to put same parameter as a method declaration .h file
still i am getting above error. so, how could i solve this error?
Hi.
I want to comment something about "About 64-bit ARM, x86 and x64 Android Devices" section.
I had the same problem you coment in this section but I found the folders arm64-v8a, armeabi or x86_64 in the libs folder and not on the jniLibs.
Thank you for your fantastic plugin!!
Hi yasirkula,
thank you! Your solution accompanied by the tutorial work like a charm for me!
Just one thing you could maybe explain more clear in your tutorial:
"Open build.gradle of android module and insert the following line into dependencies, where all the other compile command(s) are located at:"
This step in the Android section is perfectly clear if you changed any gradle files before. I myself did it the first time ;) So I opened the file and put the "compile ..." line into the dependencies section I saw at first glance. But this is a sub-section of the "buildscript" section. Didn't work as could be expected than ;)
Maybe something like "into dependencies (section at top level, not a sub-set of other sections like buildscript)..." or so would help others to avoid that mistake and keep them from searching google for the android studio error message ;)
Best regards
Greg
We have tried a variety of iOS splash screen settings, but it seems that regardless of what we do we get a stretched version of the normal app splash screen when we open the Unity portion of our app. Has anyone had any luck changing the Unity splash screen when using this plugin?
Please how to use it with Ionic V1 project ? Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.