using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using System.Text.RegularExpressions; public class php : MonoBehaviour { GameObject Cube; string save_press_key; int save_press_key_number; string url = "http://localhost/unity/addscore.php"; // Start is called before the first frame update void Start() { Cube = GameObject.Find("Cube"); } public void update_score() { this.Cube = GameObject.Find("Cube"); save_press_key = this.Cube.GetComponent().press_key; save_press_key_number = this.Cube.GetComponent().press_key_number; StartCoroutine(submit_highscore(save_press_key,save_press_key_number)); Debug.Log(save_press_key); Debug.Log(save_press_key_number); //int score = ArrowController.eat_arrow; //StartCoroutine(submit_highscore("Unity+PHP",score)); //Debug.Log(score); } IEnumerator submit_highscore(string player_name, int player_score) { WWWForm form = new WWWForm(); form.AddField("action","submit_highscore"); form.AddField("name",player_name); form.AddField("score",player_score); WWW www = new WWW(url,form); yield return www; if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); } Debug.Log(www.text); } // Update is called once per frame void Update() { } }