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 danhanly · May 23, 2012 at 09:51 AM · iosapplication.loadlevel

Application.LoadLevel not working on iOS

I have created a script that handles all interface buttons.
This script handles navigation to new scenes and button press states etc.

When I test, with Unity Remote 3, I get no issues, but obviously, that runs on my desktop. When I try to build for iOS, tapping the button will not switch scene.

Here is my Update() code:

 if(navigate){
     if(Time.time > delayedTime){
            Application.LoadLevel(targetSceneOrAction);
     }
 }

I have a fade out script on the camera, and this part just checks to see if the screen has fully faded (via a delayed time) and if it has, navigate to the next scene.

The targetSceneOrAction variable is a String which is public (allowing me to set it in the inspector for each button on an individual basis).

A Debug.Log of targetSceneOrAction reveals the correct string, and as mentioned, it works fine whilst testing within Unity.

On button press, the variable navigate is set and then the above function is accessible from the Update()

Are there any restrictions I need to be aware of when building for iOS.
At the moment, my app won't navigate from the homescreen and it's hugely inconvenient.
All in all, this script is one of the most simple processes in my app, there's nothing hugely complex, so it's kinda alarming that it's not working...

Thanks in advance for any help you can offer!

UPDATE

 Application.LoadLevel(1);

With an indexed integer seems to work, though the very nature of the script is that anything can be passed to it to dynamically manage the scene switching. Is there any way I can do this through strings?

REQUESTED

 if (Input.touchCount>0)
     for(var t in Input.touches){
         if(t.phase == TouchPhase.Began && guiTexture.HitTest(t.position))
             ButtonTapped();
          else if(t.phase == TouchPhase.Ended && guiTexture.HitTest(t.position))
               ResetButton();
         }
     else
            ResetButton();

My input detection works fine, both on build in iOS and in Unity Remote 3. ButtonTapped() switches the guitexture to a button down style state, and reset button switches it back.

It also wouldn't be a mis-spell because it works in Unity Remote

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
1
Best Answer

Answer by venkspower · May 23, 2012 at 10:11 AM

You should give it as Application.LoadLevel("targetSceneOrAction"); or give it as Application.LoadLevel(1); and set the scene number to '1' in the build settings of Unity.

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 danhanly · May 23, 2012 at 10:29 AM 0
Share

targetSceneOrAction is a variable, if I put it into quotemarks it'll take it as a literal. I need something where I can have a dynamic variable in here. It does work with 1 but it's not dynamic.

avatar image danhanly · May 24, 2012 at 03:10 PM 0
Share

I had to use an integer variable in the end. I created a public variable to handle it.

avatar image
1

Answer by Bunny83 · May 23, 2012 at 10:46 AM

How do you detect your "tap" ? Keep in mind that

 OnMouseEnter
 OnMouseOver
 OnMouseExit
 OnMouseDown
 OnMouseUp
 OnMouseUpAsButton
 OnMouseDrag

won't work on iPhone.
On other platforms Unity automatically performs a Raycast each frame to fire those events. For performance reasons this has been disabled on iPhone / mobile.

It would help to see your actual input detection...

If the Loadlevel is executed the only reason to fail would be that the scene isn't part of your build (note if you misspelled the name it's the same reason ;))

Comment
Add comment · Show 1 · 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 danhanly · May 23, 2012 at 11:00 AM 0
Share

I've updated my question. Thanks for your help!

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

6 People are following this question.

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

Related Questions

Application.Load strange problem on iOS 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Application.LoadLevel(); Changes lighting 1 Answer

Resources.Load fails when called the second time 3 Answers

Unity3D in a native iOS application woes 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