user9328598
user9328598

Reputation:

Why does not OpenURL work?

I create an ordinary game on android. I want to add some buttons with links to sites, but I have an error.

...\script\Application.cs(16,16): Error CS0117: 'Application' does not contain a definition for 'OpenURL' (CS0117) (Assembly-CSharp)

Maybe I need to add some libraries?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Application : MonoBehaviour {

    //Button
    public void SiteAction() {
        Application.OpenURL("http:// link");
    }
}

Upvotes: 2

Views: 1059

Answers (1)

Hamid Yusifli
Hamid Yusifli

Reputation: 10137

UnityEngine namespace already contains class with the name Application, change your class name or call your method as shown below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Application : MonoBehaviour {

void Start () {

}


//Button
public void SiteAction() {
    UnityEngine.Application.OpenURL("http:// link");
}

}

Upvotes: 3

Related Questions