Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Vito217 committed Apr 26, 2021
1 parent 0fafcfa commit 62bdc00
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 288 deletions.
29 changes: 25 additions & 4 deletions Assets/Scripts/UI/Objects/DesktopView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.UI;

public class DesktopView : InitializeBehaviour
Expand All @@ -14,13 +15,14 @@ public class DesktopView : InitializeBehaviour
private bool keepRequesting = true;
private Vector2 coords = Vector2.zero;

private HttpClient streamerClient;
//private HttpClient streamerClient;

public override IEnumerator innerStart()
{
streamerClient = new HttpClient();
//streamerClient = new HttpClient();
//ReadFromURL();

ReadFromURL();
StartCoroutine(RequestForImage());
return base.innerStart();
}

Expand All @@ -33,6 +35,7 @@ public void OnPointerClick(BaseEventData data)
coords = Vector2Int.RoundToInt(new Vector2(hitLocalPosition.x + delta.x, delta.y - hitLocalPosition.y));
}

/**
async void ReadFromURL()
{
while (keepRequesting)
Expand Down Expand Up @@ -63,10 +66,28 @@ async void ReadFromURL()
catch { }
}
}
**/

IEnumerator RequestForImage()
{
while (keepRequesting)
{
string data = click + " " + coords.x + " " + coords.y;
if (click) click = false;
using (UnityWebRequest uwr = UnityWebRequest.Post(streamerIP, data))
{
yield return uwr.SendWebRequest();
byte[] result = uwr.downloadHandler.data;
Texture2D t = new Texture2D(1, 1); t.LoadImage(result);
GetComponent<RectTransform>().sizeDelta = new Vector2(t.width, t.height);
img.sprite = Sprite.Create(t, new Rect(0, 0, t.width, t.height), new Vector2(t.width * .5f, t.height * .5f));
}
}
}

private void OnDestroy()
{
keepRequesting = false;
streamerClient.Dispose();
//streamerClient.Dispose();
}
}
235 changes: 0 additions & 235 deletions Logs/shadercompiler-UnityShaderCompiler.exe0.log

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe1.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe10.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe11.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe2.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe3.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe4.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe5.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe6.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe7.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe8.log

This file was deleted.

4 changes: 0 additions & 4 deletions Logs/shadercompiler-UnityShaderCompiler.exe9.log

This file was deleted.

4 changes: 2 additions & 2 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"com.unity.sysroot.linux-x86_64": "0.1.15-preview",
"com.unity.terrain-tools": "3.0.2-preview.3",
"com.unity.test-framework": "1.1.24",
"com.unity.textmeshpro": "3.0.4",
"com.unity.textmeshpro": "3.0.6",
"com.unity.toolchain.win-x86_64-linux-x86_64": "0.1.19-preview",
"com.unity.ugui": "1.0.0",
"com.unity.vectorgraphics": "2.0.0-preview.14",
"com.unity.vectorgraphics": "2.0.0-preview.15",
"com.unity.xr.interaction.toolkit": "1.0.0-pre.3",
"com.unity.xr.management": "4.0.1",
"com.unity.xr.oculus": "1.8.1",
Expand Down
15 changes: 12 additions & 3 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"url": "https://packages.unity.com"
},
"com.unity.textmeshpro": {
"version": "3.0.4",
"version": "3.0.6",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down Expand Up @@ -147,12 +147,21 @@
}
},
"com.unity.vectorgraphics": {
"version": "2.0.0-preview.14",
"version": "2.0.0-preview.15",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.ugui": "1.0.0"
"com.unity.ugui": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0"
},
"url": "https://packages.unity.com"
},
Expand Down

0 comments on commit 62bdc00

Please sign in to comment.