-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can our Cocos support some of the Unity Android/IOS builds? #17810
Comments
Not our cocos,It is cocos.Not some of,should be the same of. |
How can I call Android code in the game script like Unity does? Call the native API directly instead of via a bridge. |
And StreamingAssets are directly accessible in scripts and support building multiple platforms |
https://docs.cocos.com/creator/3.8/manual/zh/advanced-topics/native-secondary-development.html |
https://docs.cocos.com/creator/3.8/manual/zh/asset/bundle.html |
Am I not clear? I don't even know what to say. @minggo Please have a look. I've been using cocos for 4 years, and what I want to talk about is adding direct calls to native apis instead of bridging implementations. For example, the following C# code ` AndroidJavaClass unityPlayer_ = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
That was bridge |
What about the nativescript approach this.client = com.xx.sdk.xx; |
It is indeed a kind of bridge, but it can be implemented in the form of calling the native API directly from within the script |
cocos' native is JNI. It is a framework what android supported.C# is not C++,so unity add a custom bridge. |
and this is that java invoke javascript |
Use Case
When using Unity I can put some Android developed features wrapped into an aar package under Assets/Plugins/Android. It is also possible to pre-modify the contents of mainTemplate.gradle, settingsTemplate.gradle, AndroidManifest.xml.
Problem Description
Cocos doesn't have that right now.
Proposed Solution
Similar to the function under Unity Assets/Plugins, for example, I can encapsulate the Android developed function into an aar package and put it into Assets/Plugins/Android. You can pre-modify the contents of mainTemplate.gradle, settingsTemplate.gradle, AndroidManifest.xml.
StreamingAssets folder function, will build the platform needs to be placed in the assets of the resources directly into this.
3.Calling Android native API through AndroidJavaObject and AndroidJavaClass classes provided by Unity. this way allows you to call Android Java code in C# scripts without writing JNI interfaces.
This is the current gap I see between doing native packages and using Unity.
Putting in the next big release support can all be genuinely desirable with this kind of alignment feature.
How it works
No response
Alternatives Considered
Just implement something similar
Additional Information
No response
The text was updated successfully, but these errors were encountered: