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
2
Question by smtabatabaie · Apr 16, 2014 at 03:35 PM · androidandroidjavaobjectintent

Passing parameter from native android

Hi , I want to pass parameters between my Android native code and my Unity project. I can pass variable from my Unity project to my native android code but I haven't found a way to pass parameters from my native code to my Unity project.

I'll appreciate if someone can help me with this.

thanks very much

Comment
Add comment · Show 7
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 kirankiru · Aug 05, 2015 at 06:38 AM 0
Share

@smtabatabaie did you find any solution??

avatar image smtabatabaie · Aug 05, 2015 at 07:04 AM 0
Share

Yes, I don't know exactly which post , but it was a post on unity answers , search for it and you should find it ,if not let me know

avatar image kirankiru · Aug 05, 2015 at 11:32 AM 0
Share

@smtabatabaie okay will search for the post. if i didn't find i will get back to you. thanks for your reply

avatar image meat5000 ♦ · Aug 05, 2015 at 12:19 PM 0
Share

I posted a bunch of Android plugin links in this page. One of them has the information you are looking for.

avatar image kirankiru · Aug 05, 2015 at 12:22 PM 0
Share

@smtabatabaie couldn't find any. if you could give me a example or pseudocode it will be really helpful

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Mohsenasm · Aug 05, 2015 at 12:48 PM

you can use this method to call a C# (or JS) method in unity with a string parameter:

 UnityPlayer.UnitySendMessage(your_gameObject_name, your_method_Name, "message");

if you want to pass more parameter you can call your_method to get more variable:

  // in java
 
  UnityPlayer.UnitySendMessage(your_gameObject_name, your_method_Name, "Ready");

  //  ...

  public static int int_param;
  public static int getnum(){
       return int_param;
  }
 



 // in C#
 
 public void your_method_Name(string message){
     if (message == "Ready"){
          int param = your_java_class.CallStatic<int>("getnum");
          // ...
 
     }
 }







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 kirankiru · Aug 05, 2015 at 02:25 PM 0
Share

@$$anonymous$$ohsenasm , @smtabatabaie , @meat5000 thanks a lot,it worked.

avatar image seidlfranz · Apr 06, 2017 at 08:23 AM 0
Share

I cann't find this function your are talking about, is there any other way to pass parameters to Unity?

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

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

Related Questions

Android Share intent Twitter not working? 0 Answers

NoSuchMethodError when calling putExtra 0 Answers

Read intent from Android Studio in Unity 0 Answers

Unity Android app crashes when activated a few times with Android's SDK's startActivity(intent). 1 Answer

Android Plugin in Unity - No Return Value 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