void OnEnable() { if (!webView) { // create webView webView = CreateInstance <WebViewHook>(); } }
public WebSocketHook(int port, WebViewHook webView) { // add WebSocketHook to webView too this.port = port; this.webView = webView; webView.LocationChanged += UpdateDefinitions; UpdateDefinitions(""); server = new WebSocketServer("ws://127.0.0.1:" + port + ""); server.AddWebSocketService <WSS>("/ws", (e) => { e.hook = this; }); server.Start(); }
void OnEnable() { if (!webView) { // Create webView webView = CreateInstance <WebViewHook>(); } // Make the server. // The server is not serializable so there's // no need to check if this exist or not. socket = new WebSocketHook(9369, webView); // Hook window.data to javascript hook = socket.Add("data", () => data, (x) => { data = x; EditorApplication.delayCall += () => Repaint(); }); }