如何在Unity3D中使用SocketIO
How to use SocketIO in Unity3D
我发现这个 link 可以统一使用 socket.io,但我无法配置它。
这是我的 Unity 代码:
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
void Start () {
GameObject go = GameObject.Find("SocketIO");//GameObject returns Null
SocketIOComponent socket = go.GetComponent<SocketIOComponent>();
}
void Update () {
}
}
指南说我必须"Configure the url where your Socket.IO server is listening"但我做不到。
如有任何帮助,我们将不胜感激!
对于有此问题的其他人。
我没有在游戏中添加 SocketIO 预制件(在游戏层次结构中拖放),这就是我收到错误的原因。只需在 Game Hierarchy 中添加预制件并从检查器更改服务器地址。
我发现这个 link 可以统一使用 socket.io,但我无法配置它。
这是我的 Unity 代码:
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
void Start () {
GameObject go = GameObject.Find("SocketIO");//GameObject returns Null
SocketIOComponent socket = go.GetComponent<SocketIOComponent>();
}
void Update () {
}
}
指南说我必须"Configure the url where your Socket.IO server is listening"但我做不到。
如有任何帮助,我们将不胜感激!
对于有此问题的其他人。
我没有在游戏中添加 SocketIO 预制件(在游戏层次结构中拖放),这就是我收到错误的原因。只需在 Game Hierarchy 中添加预制件并从检查器更改服务器地址。