Unity UnityWebRequest 带用户名密码

string authenticate(string username, string password)
    {
        string auth = username + ":" + password;
        auth = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(auth));
        auth = "Basic " + auth;
        return auth;
    }
  IEnumerator xxxxx(string url)
    {
        string authorization = authenticate("xxx", "xxx");

        while (true)
        {
            UnityWebRequest unityWebRequest = new UnityWebRequest(url);

            unityWebRequest.SetRequestHeader("AUTHORIZATION", authorization);

            yield return unityWebRequest.SendWebRequest();

            .....
        }
        
        
    }

猜你喜欢

转载自blog.csdn.net/lvcoc/article/details/126971569