Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by bingosabi · Jul 27, 2016 at 07:16 PM · androidunity5transparentnative

Unity5 Transparent UnityPLayer view in Android

As part of an AR project for a client, we need to to overlay a UnityPlayer on Android on top of a camera feed from Vuforia. We originally opted to not use the Unity plugin from Vuforia as we also need to shuttle Vuforia image captures to a 3rd party barcode scanning library, and had hoped to only incur the memory and processor footprint of Unity once an AR target was identified by Vuforia. We additionally have native components (views) which we need to overlaid on top of the the unity player.

The general approach we followed is documented here : http://answers.unity3d.com/questions/494767/unityplayer-view-with-transparent-background.html Change the zOrderOnTop flag and the background transparency on the GlSurfaceHolderView, and do use the UnityPlayer as the renderer. Here is a working example of this, where the Red background is visible behind the unity object:

Example Source Code is available here: https://deloitteus.sharefile.com/d-s7080526180a496b9

This approach is working for us on Unity 4.2.2f1 However, in Unity 4.3 and up, Unity changed the architecture so that rendering occurs natively and without the UnityPlayer implementing GLRenderer. We would release our working app on Unity 4.2.2f1, however, it contains libraries have Text relocations which means they can't run on Run level 23 on Android (Marshmallow), which we now need to support.

We hence are exploring the transparent unity view on top of a native Android view on Unity5, which does not suffer from the text relocation issue, and would be the preferable future solution. As the GLSurfaceView renderer is not exposed in this version, we tried reflection to gain access to it, and also tried to use blend modes, although these don't appear to work with SurfaceViews. The non working example of this can be found here: https://deloitteus.sharefile.com/d-s3f9ce2d8e0449119 Attempted Unity5 Transparent background camera approach: (not transparent)

Does anyone have any pointers on how to 1) An approach to overlay a UnityPlayer on-top of a native Android view in Unity 5.3.2f1 or above? (related to http://answers.unity3d.com/questions/494767/unityplayer-view-with-transparent-background.html) What I've tried: a) Using reflection to modify the underlying surface view to set the ZOrderOnTop flag.
b) Using reflection to the modify the underlying surface view background paint c) Changing the blend mode of the layer paint on the underlying surface view.

2) Alternately, anyone have a solution to text relocations on a 4.2.x version which is compatible with Marshmallow?

Target Run Level 22: 07-26 13:09:32.393 8229-8229/? W/linker: /data/app/com.sample.app/lib/arm/libmain.so has text relocations. This is wasting memory and prevents security hardening. Please fix. 07-26 13:09:32.399 8229-8229/? W/linker: /data/app/com.sample.app/lib/arm/libmono.so has text relocations. This is wasting memory and prevents security hardening. Please fix. 07-26 13:09:32.487 8229-8229/? W/linker: /data/app/com.sample.app/lib/arm/libunity.so has text relocations. This is wasting memory and prevents security hardening. Please fix.

Target Run Level 23: Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.sample.app/lib/arm/libmain.so: has text relocations at java.lang.Runtime.loadLibrary(Runtime.java:372) at java.lang.System.loadLibrary(System.java:1076) at com.unity3d.player.UnityPlayer.a(Unknown Source) at com.unity3d.player.UnityPlayer.(Unknown Source) at com.sample.app.UnityPlayerSubclass.(UnityPlayerSubclass.java:12) at com.sample.app.UnityViewWrapperImpl.setupView(UnityViewWrapperImpl.java:37) at com.sample.app.UnityViewWrapperImpl.(UnityViewWrapperImpl.java:32) at com.sample.app.UnityWrapperImpl.createUnityView(UnityWrapperImpl.java:17)

Thanks, Ben

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yuguoba · Sep 11, 2016 at 04:34 AM 0
Share

I have same requirement and want to get a solution with unity 5.x , any new method or comments about it ?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by danw_unity · Aug 15, 2016 at 10:00 PM

Hi Ben,

In general this isn't possible on Android with the latest Unity versions (not sure of which exact version made this impossible). For maximum device compatibility, Unity renders to a buffer and then blits it to the device backbuffer as a final step. The final blit does not support alpha.

If I understand correctly, you want to be using Vuforia, then have the Unity app come to life when you detect some AR target. At that point Unity would be using the Vuforia plugin anyway, correct? I don't quite understand how having the transparent backbuffer in Unity saves memory and performance in this scenario. Could you give me some more details please?

Regards,

Dan

Unity Support

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sbodi · Sep 15, 2016 at 04:55 PM 0
Share

Hey danw_unity,

What Ben meant was: Vuforia and Unity will exists in activity at same time (this is the order Vuforia -> Unity[technically it is GLSurfaceView(transparent BG) with UnityPlayer as its renderer] -> Android views).

Vuforia - which has the camera feed(to scan targets) and unity(since UnityPlayer exposes Renderer in 4.2.2 version, we have a GLSurfaceView with transparent background with UnityPlayer as it renderer) to display some 3D models when a target is identified.

The problem with Unity 5.x version, it doesn't expose its renderer which will be done natively.

I hope its clear now.

We are still looking to find a solution for this. Please let us know if you have any alternative.

Regards, Satish Bodi

avatar image UnityForiOS sbodi · Jan 09, 2017 at 03:22 AM 0
Share

I want to overlay UnityPlayer view on top of Native Android view where only the 3D objects being drawn and no camera background (transparent background) with Unity 5.x version Did you have new method about it?thanks

avatar image
0

Answer by bingosabi · Jan 10, 2017 at 07:46 AM

We didn't ever figure this out on Unity 5.x on Android. One option which was suggested was purchasing a source code license where you could tinker with the underlying renderers. I expect that this would be prohibitively expensive. You'd need to contact Unity directly to pursue that option.

More broadly, I'd recommend against attempting to embed Unity in a primarily Native app. It's not how it's intended to be used.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LoungeKatt · May 21, 2017 at 04:53 AM 0
Share

Actually, Unity is somewhat restrictive in the grand scope of development and their $$anonymous$$m may not have intentionally remove this capability, so much as they seem unaware how to restore it. By offering the source at a cost, they both avoid trying to restore the capability and profit from those with enough interest in doing it themselves.

You can see from numerous forum posts about this topic that they either ignore requests for how to do it, refer back to using Unity 4.2, or reference using onDisplayChanged. onDisplayChanged will replace the surface that is used by a Unity player, but will also replace the entire rendered content on the surface. Not being able to manipulate the view is just poor design. There is no logical reason to block access other than forcing proprietary restrictions.

I develop my entire application in Android Studio, then import that library into Unity to perform the build. I use a makeshift library from building the Unity project with an empty jar/aar to fill reference requirements for Android Studio's build that is, in turn, put back into Unity. While the Unity contribution to the project improves the visual appeal, it pales in comparison to what is being done in the Android Studio portion. Replicating that in Unity would be tedious, at best.

It is possible to do a lot of things in Unity that aren't advertised or intended, but are highly effective and often more efficient. The number of bugs alone give a good indication that the people designing the editor may not always have a good grasp on how it will be used.

avatar image weixiaowang · May 31, 2017 at 03:19 AM 0
Share

Have you solve this?I encountered a similar problem,thanks

avatar image
0

Answer by clementmangin · Aug 13, 2019 at 03:33 PM

For anyone still stuck on this issue, there is a new option in Unity, "Preserve framebuffer alpha", and this post details how it works: https://forum.unity.com/threads/2017-3-0b4-transparency-on-android.499673/#post-3252597

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to translate ArrayList to C# using AndroidJavaClass? 1 Answer

Reading XML Data for andriod 1 Answer

Can't access android mediastore 1 Answer

Buttons touches dont work if touch splash screen 1 Answer

Daydream compatible Unity versions? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges