Unity3D 多人登录
Unity3D Multiplayer logins
所以我有这个看起来像这样的 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 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 并检查帐户是否存在。
WebRequest
class 在 System.Net
命名空间中,而不是 WebRequest 命名空间(不存在)。指定
using System.Net;
而不是
using WebRequest;
更好的是,只需删除 using WebRequest
,因为 System.Net
已经在您的命名空间列表中。
所以我有这个看起来像这样的 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 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 并检查帐户是否存在。
WebRequest
class 在 System.Net
命名空间中,而不是 WebRequest 命名空间(不存在)。指定
using System.Net;
而不是
using WebRequest;
更好的是,只需删除 using WebRequest
,因为 System.Net
已经在您的命名空间列表中。