Skip to content
Snippets Groups Projects
Commit 5661040a authored by John Schihada's avatar John Schihada
Browse files

Making Pushout- and newAssignment-Routines non-blocking

parent 2be92d26
No related branches found
No related tags found
No related merge requests found
...@@ -41258,6 +41258,11 @@ PrefabInstance: ...@@ -41258,6 +41258,11 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 4004370943283418989, guid: c1d50ceff6c06de40b71063574eba754,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: magicButtonTrigger
objectReference: {fileID: 0}
- target: {fileID: 8372521933580734050, guid: c1d50ceff6c06de40b71063574eba754, - target: {fileID: 8372521933580734050, guid: c1d50ceff6c06de40b71063574eba754,
type: 3} type: 3}
propertyPath: m_AnchorMax.x propertyPath: m_AnchorMax.x
...@@ -50,6 +50,7 @@ void Update() ...@@ -50,6 +50,7 @@ void Update()
} }
/* /*
//Todo before capturing: Make directories "UFrameIT-Screenshots/Unity_ScreenCapture" in project folder
else if (Input.GetKeyDown(ScreenshotKey)) { else if (Input.GetKeyDown(ScreenshotKey)) {
ScreenCapture.CaptureScreenshot("UFrameIT-Screenshots\\Unity_ScreenCapture\\Capture.png"); ScreenCapture.CaptureScreenshot("UFrameIT-Screenshots\\Unity_ScreenCapture\\Capture.png");
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
using static JSONManager; using static JSONManager;
using static FactManager;
public class ParsingDictionary { public class ParsingDictionary {
......
using System.Collections.Generic; using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using TMPro; using TMPro;
using UnityEngine.Networking; using UnityEngine.Networking;
...@@ -30,7 +31,7 @@ void Start() ...@@ -30,7 +31,7 @@ void Start()
parameterDisplayHint.AddListener(animateScrollParameter); parameterDisplayHint.AddListener(animateScrollParameter);
CompletionsHintEvent.AddListener(animateCompletionsHint); CompletionsHintEvent.AddListener(animateCompletionsHint);
NewAssignmentEvent.AddListener(newAssignment); NewAssignmentEvent.AddListener(newAssignmentTrigger);
} }
public void setScroll(Scroll s) public void setScroll(Scroll s)
...@@ -61,8 +62,19 @@ public void setScroll(Scroll s) ...@@ -61,8 +62,19 @@ public void setScroll(Scroll s)
} }
} }
public void magicButton() public void magicButtonTrigger() {
StartCoroutine(magicButton());
}
IEnumerator magicButton()
{
bool workDone = false;
while (!workDone)
{ {
// Let the engine run for a frame for not letting the game freeze
yield return null;
string answer = sendView("/scroll/apply"); string answer = sendView("/scroll/apply");
if (answer == null) if (answer == null)
...@@ -70,26 +82,46 @@ public void magicButton() ...@@ -70,26 +82,46 @@ public void magicButton()
Debug.Log("DAS HAT NICHT GEKLAPPT"); Debug.Log("DAS HAT NICHT GEKLAPPT");
//TODO: hier ne Art PopUp, wo drin steht, dass das nicht geklappt hat //TODO: hier ne Art PopUp, wo drin steht, dass das nicht geklappt hat
PushoutFactFailEvent.Invoke(null); PushoutFactFailEvent.Invoke(null);
return;
} }
else
{
Scroll.ScrollApplicationInfo pushout = JsonConvert.DeserializeObject<Scroll.ScrollApplicationInfo>(answer); Scroll.ScrollApplicationInfo pushout = JsonConvert.DeserializeObject<Scroll.ScrollApplicationInfo>(answer);
readPushout(pushout.acquiredFacts); readPushout(pushout.acquiredFacts);
} }
public void newAssignment() workDone = true;
}
}
public void newAssignmentTrigger() {
StartCoroutine(newAssignment());
}
IEnumerator newAssignment()
{ {
bool workDone = false;
while (!workDone)
{
// Let the engine run for a frame for not letting the game freeze
yield return null;
string answer = sendView("/scroll/dynamic"); string answer = sendView("/scroll/dynamic");
if (answer == null) if (answer == null)
{ {
Debug.Log("DAS HAT NICHT GEKLAPPT"); Debug.Log("DAS HAT NICHT GEKLAPPT");
return;
} }
else
{
Scroll.ScrollDynamicInfo scrollDynamicInfo = JsonConvert.DeserializeObject<Scroll.ScrollDynamicInfo>(answer); Scroll.ScrollDynamicInfo scrollDynamicInfo = JsonConvert.DeserializeObject<Scroll.ScrollDynamicInfo>(answer);
processScrollDynamicInfo(scrollDynamicInfo); processScrollDynamicInfo(scrollDynamicInfo);
} }
workDone = true;
}
}
private string sendView(string endpoint) private string sendView(string endpoint)
{ {
string body = prepareScrollAssignments(); string body = prepareScrollAssignments();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment