// Update is called once per frame void Update() { if (Input.GetMouseButton(0)) { startTime = Time.time; } ASName = SceneManager.GetActiveScene().name; //没有处在第一场景并且10秒之内没有反应 if (ASName != "FirstScene" && ((Time.time - startTime) > 10.0f)) { //如果提交之后 if (NetworkData.isSubmit) { Debug.Log("TimeSceneControl" + "Update"); //发送断开连接信号 SocketConnect.getSocketInstance().SendInt(NetworkData.SENDDISCONNECT); SocketConnect.getSocketInstance().close(); //结束展示 NetworkData.isSubmit = false; } //卸载当前场景 SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene()); //加载第一场景 SceneManager.LoadScene("FirstScene"); } }
private void OnApplicationQuit() { Debug.Log("退出程序连接"); //程序退出时关闭连接 if (SocketConnect.getSocketInstance() != null) { Debug.Log("OnApplicationQuit"); SocketConnect.getSocketInstance().close(); } }
void RotateModel(float moveX, float moveY) { moveX /= 5.0f; Move_Y /= 10.0f; up = model.worldToLocalMatrix * model.up; right = model.worldToLocalMatrix * model.right; model.Rotate(up, -moveX, Space.World); model.Rotate(right, moveY, Space.World); if (NetworkData.isSubmit) { Debug.Log("RotateModel"); //发送数据 SocketConnect.getSocketInstance().SendInt(NetworkData.SENDROTATION); SocketConnect.getSocketInstance().SendFloat(model.eulerAngles.x); SocketConnect.getSocketInstance().SendFloat(model.eulerAngles.y); SocketConnect.getSocketInstance().SendFloat(model.eulerAngles.z); } }
//点击提交事件 void OnSubmitClick(GameObject go) { Debug.Log("点击提交"); if (flag) //协程已经启动 { Debug.Log(" submit coroutine return "); return; } Debug.Log("=========Connect============"); //获得连接实例 sc = SocketConnect.getSocketInstance(); //这是提交信号为true NetworkData.isSubmit = true; //发送请求链接信号 sc.SendInt(NetworkData.SENDCONNECT); flag = true; StartCoroutine(WaitSign()); }