UnityTest

 2025.01.05 unity  
 2024.12.22 unity  
 2024.12.22 unity  
 2024.12.22 unity  
 2024.12.22 未分類  

page.phpテンプレートを利用しています。

TotalScore


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;/
using UnityEngine.Networking;//ネットワークを使用する際に使う
using TMPro;

public class Total : MonoBehaviour
{
    private bool toggle;
   public TextMeshProUGUI MyText;
    void Start()
    {
      //  MyText.GetComponent();
        toggle = true;    //初期設定
    }
    public void ToClick()
    {
        if (toggle)
        {
            StartCoroutine("Access");
            toggle = false;
        }
        else
        {
            MyText.GetComponent().text = "";
            toggle = true;
        }
    }
    private IEnumerator Access()//呼び出されると以下のPHPを実行
    {
        StartCoroutine(Post("https://kyou.stars.ne.jp/myunity/scoredata.php"));
        yield return 0;
    }

    private IEnumerator Post(string url)//Postでデータを送受信
    {
        WWWForm form = new WWWForm();
        using (UnityWebRequest www = UnityWebRequest.Post(url, form))
        {
            yield return www.SendWebRequest();

      MyText.GetComponent().text = www.downloadHandler.text;
      //PHPで返したデータベースの値をUNITYのテキストに表示する
        }
    }
}

月別
固定ページ
サンプルページ