private void Start() { effectQ = new Queue <EffectData>(); ws = new WebSocket("ws://" + TitleBtnMgr.IPAddress + ":3000/"); ws.OnOpen += (sender, e) => { Viewer.GetComponent <LogViewer>().AddLine("WebSocket Open"); }; ws.OnMessage += (sender, e) => { Viewer.GetComponent <LogViewer>().AddLine("Data: " + e.Data); var recvs = e.Data.Split(); if (recvs[0] == "EFFDATA") { var effdata = JsonUtility.FromJson <EffectData>(recvs[1]); effectQ.Enqueue(effdata); } }; ws.OnError += (sender, e) => { Viewer.GetComponent <LogViewer>().AddLine("WebSocket Error Message: " + e.Message); }; ws.OnClose += (sender, e) => { Viewer.GetComponent <LogViewer>().AddLine("WebSocket Close"); }; ws.Connect(); }
public void BtnSend_OnClick() { var ws = Client.GetComponent <WSClient>().ws; ws.Send("REQ TEST EFF"); Viewer.GetComponent <LogViewer>().AddLine("REQ TEST EFF"); }
public void OnButtonClicked() { Viewer.GetComponent <LogViewer>().AddLine("Button Clicked. " + DateTime.Now); var obj = new EffectData(); obj.EffectName = "Laser01"; obj.Position = new Vector3(8.0f, -16.0f, 27.0f); obj.Rotation = Quaternion.Euler(0, -90, 0); obj.LocalScale = new Vector3(1.0f, 1.0f, 1.0f); if (Echo.SendQ != null) { Echo.SendQ.Enqueue(obj); } }
private void ShakeCheck() { preAcceleration = Acceleration; Acceleration = Input.acceleration; if (Vector3.Dot(preAcceleration, Acceleration) >= 2.35) { if (ShakeCount >= Shake) { var ws = Client.GetComponent <WSClient>().ws; ws.Send("LIKE"); Viewer.GetComponent <LogViewer>().AddLine("Send LIKE!"); ShakeCount = 0; } LastTick = Environment.TickCount; ShakeCount++; } if ((Environment.TickCount - LastTick) >= 2 * 1000) { ShakeCount--; LastTick = Environment.TickCount; } Meter.GetComponent <ShakeMeter>().Value = (float)ShakeCount / Shake; }
private void Start() { server = new WebSocketServer(3000); server.AddWebSocketService("/", () => new Echo(Viewer)); server.Start(); if (server.IsListening) { Viewer.GetComponent <LogViewer>().AddLine("< SERVER LISTENED >"); } }
private DeviceOrientation currentOrientation; // デバイスの向き // Use this for initialization private void Start() { baseRotate = this.GetComponent <RectTransform>().rotation; ApplyDeviceRotate(); // ウェブカメラデバイスの列挙 var devices = WebCamTexture.devices; if (DEBUG) { for (var i = 0; i < devices.Length; i++) { Viewer.GetComponent <LogViewer>().AddLine("Cam[" + i + "] : " + devices[i].name); } } // デバイスが存在したらRawImageのテクスチャをウェブカメラにする if (devices.Length > 0) { if (CamNum > devices.Length) { CamNum = 0; } var wcam = new WebCamTexture(devices[CamNum].name); wcam.Play(); var webcamTexture = new WebCamTexture(devices[CamNum].name, wcam.width, wcam.height, FPS); wcam.Stop(); this.GetComponent <RawImage>().material.mainTexture = webcamTexture; webcamTexture.Play(); } else { Debug.LogError("Webカメラを検出できません!"); if (DEBUG) { Viewer.GetComponent <LogViewer>().AddLine("Webカメラを検出できません!"); } } }
private void Update() { foreach (var eff in effects) { if (!eff.Handle.HasValue) { continue; } var h = eff.Handle.Value; var tran = eff.Obj.transform; if (h.exists) { h.SetLocation(tran.position); h.SetRotation(tran.rotation); h.SetScale(tran.localScale); } else if (eff.DoLoop) { Play(eff); } else { h.Stop(); eff.Handle = null; } } effects.RemoveAll(eff => eff.Handle == null); timeleft -= Time.deltaTime; if (DEBUGMODE && Viewer != null) { if (timeleft <= 0.0f) { timeleft = debugLogTiming; foreach (var eff in effects) { Viewer.GetComponent <LogViewer>().AddLine(string.Format("N:{0} P:{1} R:{2} S:{3}", eff.EffectName, eff.Obj.transform.position, eff.Obj.transform.rotation, eff.Obj.transform.localScale)); } } } }