Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Need mobile help please

Discussion in 'Scripting' started by WernerO, Jan 15, 2015.

  1. WernerO

    WernerO

    Joined:
    Jan 15, 2015
    Posts:
    5
    Hi guys, can anyone please help me.

    I am using this code to open a website by walking into a trigger.

    Application.OpenURL("www.google.com");

    On computer it works perfectly.
    But in my app on my Android if I walk into it it wont open a web browser.

    this is my code.
    (ps i also have a white cube popping up just to see if the trigger works.)

    any help please Thanks guys




    var face : GameObject;

    var hasplayed = false;
    var entertrigger = false;
    var synch_lock = false;




    function Start () {

    entertrigger = false;
    face.renderer.enabled = false;



    }


    function OnTriggerEnter (other : Collider) {

    entertrigger = true;

    }


    function Update () {
    if(!synch_lock){
    synch_lock = true;
    if (entertrigger == true){
    face.renderer.enabled = true;
    Application.OpenURL("www.google.com");
    entertrigger = false;
    }
    synch_lock = false;
    }

    }
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,523
    On Android, you need to add "http://":
    Code (csharp):
    1. Application.OpenURL("http://www.google.com");
     
  3. WernerO

    WernerO

    Joined:
    Jan 15, 2015
    Posts:
    5
    I Tried that aswell, but on any android device i tested it on it wont open a browser, but on the emulator on my computer it works.
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,523
    Check your Player Settings (File > Build Settings, then Player Settings). Make sure Internet Access is set to 'Require'.