Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by eliascanaza · Oct 05, 2013 at 07:07 AM · androidjava

How put Android native code into c# unity

Hi everyone ... how i can put android native code into c# unity, i need access for example: list contact or camera from my phone... and then i need work with that.

something like:

 using UnityEngine; 
 {IMPORT JAVA CODE}
 public class NewBehaviourScript : MonoBehaviour { 
 
     void Start () { 
               {JAVA CODE}
     } 
 } 

thanks

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by whydoidoit · Oct 05, 2013 at 07:36 AM

There's no way to do that. You can include native code as a plugin if you have Pro (Desktop) or if you use Mobile platforms.

http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html

Comment
Add comment · Show 5 · 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 whydoidoit · Oct 05, 2013 at 07:38 AM 0
Share

You can access the camera using the Webcam class in Unity and there's bound to be a plugin already written on the Asset Store for getting what you need.

avatar image eliascanaza · Oct 05, 2013 at 02:28 PM 0
Share

I found that ... this not allow me put a lot of native code sure?

    void OnGUI () { 
     string somestring; 
     AndroidJavaClass jc= new AndroidJavaClass("com.example.pluginsample.$$anonymous$$ainActivity"); 
     AndroidJavaObject jo = jc.GetStatic("instance"); 
     somestring = jo.Call("Foo"); 
     GUI.Label (new Rect (20, 20, 100, 20), somestring); 
 }
     
 In Java Class:
     
 public String Foo() { 
     return "Hello";
 }

what do you thing about that ..,

avatar image whydoidoit · Oct 05, 2013 at 02:33 PM 0
Share

You can access your own class presu$$anonymous$$g it's being loaded in the Android$$anonymous$$anifest.xml file - probably as an override to the normal Unity player...

avatar image eliascanaza · Oct 05, 2013 at 03:05 PM 0
Share

i think use that and modify Android$$anonymous$$anifest.xml but i dont now .. :D look at more information

avatar image eliascanaza · Oct 05, 2013 at 03:06 PM 0
Share

okey the other option is make a plugin java to c# ... okey i will make ... !

avatar image
0

Answer by codemaker2015 · Jul 09, 2020 at 10:48 AM

Try the following repository

Android native code in unity

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

18 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Accessing Data from a Android java class 1 Answer

How do I save a screenshot to the gallery on Android Kitkat 4.4.2 or above? 1 Answer

Issue installing apk using old Cert 1 Answer

Unity 5 seems to can't find my Android Plugin 0 Answers

Accessing variables from android java objects 1 Answer


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