Button pressed fix

This commit is contained in:
Abdul Mukheem Shaik 2024-05-28 15:42:58 +02:00
parent af1f18f463
commit cdbee665a2

@ -87,15 +87,19 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
public void OnButtonClick()
{
webSocketController = GameObject.FindGameObjectWithTag("WebController");
webSocketControllerScript = webSocketController.GetComponent<WebSocketController>();
webSocketControllerScript.ConnectWithESP32();
StartCoroutine(GetText());
if (!isButtonPressed)
{
webSocketController = GameObject.FindGameObjectWithTag("WebController");
webSocketControllerScript = webSocketController.GetComponent<WebSocketController>();
webSocketControllerScript.ConnectWithESP32();
StartCoroutine(GetText());
avatar = GameObject.FindGameObjectWithTag("Avatar");
audioControllerScript = avatar.GetComponent<AudioController>();
audioControllerScript.fn_call_AudioNarration2();
Debug.Log("Button is Clicked");
avatar = GameObject.FindGameObjectWithTag("Avatar");
audioControllerScript = avatar.GetComponent<AudioController>();
audioControllerScript.fn_call_AudioNarration2();
Debug.Log("Button is Clicked");
}
}
public void emergencyButtonClick()
{
@ -129,7 +133,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
{
Debug.Log("Received data" + www.downloadHandler.text);
ExtractDataFromJson(www.downloadHandler.text);
isButtonPressed = true; // Boolean to keep voltage updated as long as the turbine is rotating
}
}
@ -187,13 +191,13 @@ public void ExtractDataFromJson(string json)
}
}
photonView = PhotonView.Get(this);
photonView.RPC("RPC_GreenButtonClick", RpcTarget.All,windDirectionInDirectionTerms,LatestT+" C","Kista",latestWS+" m/s",true,latestWD,latestWS);
photonView.RPC("RPC_GreenButtonClick", RpcTarget.All,windDirectionInDirectionTerms,LatestT+" C","Kista",latestWS+" m/s",true,latestWD,latestWS, true);
}
[PunRPC]
public void RPC_GreenButtonClick(String windDirection,String locationTemperature,String location,String windSpeed,bool turn_WT_on_Y_Axis_val,float latestWD_val, float latestWS_val)
public void RPC_GreenButtonClick(String windDirection,String locationTemperature,String location,String windSpeed,bool turn_WT_on_Y_Axis_val,float latestWD_val, float latestWS_val,bool isButtonPressed_val)
{
isButtonPressed = isButtonPressed_val;
latestWD = latestWD_val; // Just for RPC purposes
latestWS = latestWS_val; // Just for RPC purposes
windDirValue.SetText(windDirection);