Cubeの方
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Text.RegularExpressions;
public class Defense : MonoBehaviour
{
public Text number;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Text.RegularExpressions;
public class Defense : MonoBehaviour
{
public Text number;
//衝突したとき一度だけ判定を行う
void OnCollisionEnter(Collision collision)
{
for (int i = 1; i <= 5; i++)
{
if (collision.gameObject.name == "Item (" + i.ToString() + ")")
{
number.text = i.ToString();
Debug.Log(collision.gameObject.name);
}
}
}
}
}
ボタンに入れてるscript
using UnityEngine.SceneManagement; //シーンマネジメントを有効にする
public class GameController2 : MonoBehaviour
{
public void toGameScene()
{
SceneManager.LoadScene("Scene2");
}
}
using UnityEngine.SceneManagement; //シーンマネジメントを有効にする
public class GameController2 : MonoBehaviour
{
public void toGameScene()
{
SceneManager.LoadScene("Scene2");
}
}
バージョン)
unity2019