Hey, guys. Someone knows why this didn’t work on android ? XD Sorry, i’m new on Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameController : MonoBehaviour
{
public string[,] tictactoeArray = new string[,]{ {"?", "?", "?"},
{"?", "?", "?"},
{"?", "?", "?"} };
//Row 1
public GameObject tictactoeButton00 = new GameObject();
public GameObject tictactoeButton01 = new GameObject();
public GameObject tictactoeButton02 = new GameObject();
//Row 2
public GameObject tictactoeButton10 = new GameObject();
public GameObject tictactoeButton11 = new GameObject();
public GameObject tictactoeButton12 = new GameObject();
//Row 3
public GameObject tictactoeButton20 = new GameObject();
public GameObject tictactoeButton21 = new GameObject();
public GameObject tictactoeButton22 = new GameObject();
public GameObject X = new GameObject();
public GameObject O = new GameObject();
int round = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if(hit.transform.name == tictactoeButton00.name && tictactoeArray[0,0]=="?") {
if(round % 2 == 0)
{
tictactoeArray[0,0] = "X";
round++;
Instantiate(X, new Vector3(tictactoeButton00.transform.position.x, tictactoeButton00.transform.position.y, tictactoeButton00.transform.position.z), Quaternion.identity);
}
else {
tictactoeArray[0,0] = "O";
round++;
Instantiate(O, new Vector3(tictactoeButton00.transform.position.x, tictactoeButton00.transform.position.y, tictactoeButton00.transform.position.z), Quaternion.identity);
}
}
}
}
}
private void OnMouseDown()
{
}
}