• 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 billda · Oct 07, 2014 at 03:57 PM · android

Is it possible to launch scene from java code

Hi, I am developing hybrid Unity-Android application - I've created some scenes in unity, exported is as Google android project and imported it to Android Studio. Is it possible somehow programmatically from Android code choose what scene should be launched? I know that i could maybe export every scene as different project, but the scenes differs only i small parts, 95% of code and assets is the same. So i would like to share these resources because of obvious reasons.

Thx

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 tanoshimi · Oct 07, 2014 at 04:28 PM 0
Share

I know it doesn't directly help you but, in a standalone build, you can pass command-line arguments like this:

 game.exe "LevelToLoad"

And retrieve them using, e.g.:

 string[] arguments = Environment.GetCommandLineArgs();
 Application.LoadLevel(arguments[1]);

I'm not sure how that translates to Android though - does http://forum.unity3d.com/threads/android-command-line-parameters.153225/ help at all?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Spinnernicholas · Oct 07, 2014 at 05:07 PM

In Java:

 UnityPlayer.UnitySendMessage(String GameObjectInCurrentScene, String MethodOnScriptOnGameObject, String Params);

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 billda · Oct 08, 2014 at 07:51 AM 0
Share

Well thanks, could you give me some example of usage please?

avatar image billda · Oct 08, 2014 at 10:46 AM 0
Share

Well maybe I could make some dummy scene which will contains method for calling Application.LoadLevel(scene) and I could call this method from Java Code..

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Can't generate apk 1 Answer

Run Function when user shakes mobile andriod unity c# 0 Answers

Deploying a Unity app to Android phone(s) - Issue. 0 Answers

Unity looses my Player settings 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