123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- public class DeletePoints : MonoBehaviour
- {
-
- private GameObject deleteId;
- public GameObject masterConnector;
-
- // Start is called before the first frame update
- void Start()
- {
- deleteId = null;
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- public void setDeleteVisible(GameObject delete_id) {
- this.deleteId = delete_id;
- GameObject parent = GameObject.Find("Canvas");
- Transform[] children = parent.GetComponentsInChildren<Transform>(true);
- foreach(Transform ch in children)
- {
- if(ch.gameObject.name == "DeleteButton")
- {
- ch.gameObject.SetActive(true);
- }
- }
- }
- public void setDeleteNonVisible() {
- this.deleteId = null;
-
- GameObject parent = GameObject.Find("Canvas");
- Transform[] children = parent.GetComponentsInChildren<Transform>(true);
- foreach(Transform ch in children)
- {
- if(ch.gameObject.name == "DeleteButton")
- {
- ch.gameObject.SetActive(false);
- }
- }
- }
- public void deletePoints()
- {
- if(deleteId == null)
- {
- return;
- }
- string gn = masterConnector.GetComponent<MasterCreateGame>().GetGameNumber();
- StartCoroutine(DeletePointsOnServer(gn));
- }
- public IEnumerator DeletePointsOnServer(string thisGame)
- {
- string serverUrl = "https://smarthubs.media.tuwien.ac.at/api/delete_object";
-
- string obj_id = deleteId.GetComponent<ObjectDropper>().objectId.ToString();
- // Create a Web Form
- WWWForm form = new WWWForm();
- form.AddField("game", thisGame);
- form.AddField("oid", obj_id);
- using (UnityWebRequest www = UnityWebRequest.Post(serverUrl, form))
- {
- yield return www.SendWebRequest();
- if (www.result != UnityWebRequest.Result.Success)
- {
- Debug.Log(www.error);
- // PROMPT ERROR
- //errorPanel.SetActive(true);
- }
- else
- {
- Debug.Log("Form upload complete!");
-
- }
- }
- }
- }
|