C# Unity3D多人登录
我有一个c#脚本,看起来就像这样C# Unity3D多人登录,c#,unity3d,C#,Unity3d,我有一个c#脚本,看起来就像这样 using UnityEngine; using System.Collections; using System.Net; using WebRequest; using System.IO; using System.Runtime; using System.Runtime.Remoting; public class Login_Button : MonoBehaviour { // Use this for initialization void
using UnityEngine;
using System.Collections;
using System.Net;
using WebRequest;
using System.IO;
using System.Runtime;
using System.Runtime.Remoting;
public class Login_Button : MonoBehaviour {
// Use this for initialization
void Start () {
}
public static string UserName;
public static string Password;
// Update is called once per frame
void Update () {
}
public void UserInput (string UserInput)
{
UserName = UserInput;
}
public void PassInput (string PassInput)
{
Password = PassInput;
}
public void UserName_Checked(string Menu_MultiLobby)
{
string ActiveCheck = "*************/api.php" + UserName + "&p=" + Password;
WebRequest request = WebRequest.Create(ActiveCheck);
request.Method = "GET";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string Active = reader.ReadToEnd();
reader.Close();
response.Close();
if (Active == "accepted")
{
Application.LoadLevel(Menu_MultiLobby);
}
else if (Active == "wrong")
{
}
}
}
在Unity3D中,我得到了这个错误
Assets/Login_Button.cs(4,7): error CSO246: The type of namespace name 'WebRequest' could not be found.
我使用的是MonoDevelop,我将.dll放入引用中。我需要把它放在别的地方吗?另外,如果您想知道这是怎么做的,那么它将使用php连接到mySQL并检查帐户是否存在 位于System.Net
命名空间中,而不是WebRequest命名空间(不存在)。指明
using System.Net;
而不是
using WebRequest;
更妙的是,只需使用WebRequest删除
,因为System.Net
已经在您的命名空间列表中。但他正在使用System.Net
!不是吗?我已经澄清了。见我的最后一段。他收到错误是因为WebRequest
不是有效的名称空间。这解决了该问题,但应用程序.LoadLevel();现在似乎不起作用了:(