J'ai un soucis lors du build de mon projet. Le code qui suit marche bien en Mode Editor avec remote mais lorsque je build je nai plus de detection des touchs
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.InputSystem;
using PlayFab;
using PlayFab.ClientModels;
using TMPro;
using Newtonsoft.Json;
using UnityEngine.EventSystems;
public class gameManangerScript : MonoBehaviour
{
public GameObject Perso;
private Rigidbody persoRigidBody;
private PlayerInput playerInput;
private PlayerController playerController;
public bool dejaUneCible;
public GameObject tuileCiblee;
GameObject[] cameraContainer;
public TMP_Text retour;
private void Awake()
{
persoRigidBody = Perso.GetComponent<Rigidbody>();
playerInput = Perso.GetComponent<PlayerInput>();
playerController = new PlayerController();
playerController.deplacement.Enable();
cameraContainer = GameObject.FindGameObjectsWithTag("cameraControlerGO");
retour.text = "debut";
}
// Update is called once per frame
void FixedUpdate()
{
#region deplacement // ceci marche bien
Vector2 inputVector = playerController.deplacement.move.ReadValue<Vector2>();
float speed = 8f;
persoRigidBody.AddForce(new Vector3(inputVector.x, 0, inputVector.y) * speed, ForceMode.Force);
#endregion
#region selection tuile // TODO le block raycast par UI
for (int i = 0; i< Input.touchCount; i++ ) // ceci ne marche pas
{
retour.text = "ca touche l'ecran " ;
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);
if (Physics.Raycast(ray,out hit) )
{
Debug.Log(hit.collider.name);
if (hit.collider.tag == "Tuiles")
{
retour.text = "ca touche " + hit.collider.name;
if (hit.collider.GetComponent<tuilemanager>().retournable && !dejaUneCible)
{
tuileCiblee = hit.collider.gameObject;
tuileCiblee.GetComponent<tuilemanager>().target = true;
tuileCiblee.GetComponent<tuilemanager>().enRotation = true;
dejaUneCible = true;
if (hit.collider.GetComponent<tuilemanager>().occupee)
{
Perso.GetComponent<persoControlerScript>().enRotation = true;
cameraContainer[0].GetComponent<cameraManagerScript>().enRotation = true;
}
}
}
if (hit.collider.tag != "Tuiles" && tuileCiblee.GetComponent<tuilemanager>().enRotation == false )
{
tuileCiblee.GetComponent<tuilemanager>().target = false;
tuileCiblee = null;
dejaUneCible = false;
}
}
else if ( tuileCiblee != null && tuileCiblee.GetComponent<tuilemanager>().enRotation == false)
{
tuileCiblee.GetComponent<tuilemanager>().target = false;
tuileCiblee = null;
dejaUneCible = false;
}
}
if (Input.touchCount == 0 && tuileCiblee != null && tuileCiblee.GetComponent<tuilemanager>().enRotation == false)
{
tuileCiblee.GetComponent<tuilemanager>().target = false;
tuileCiblee = null;
dejaUneCible = false;
}
#endregion
}
}
merci d'avance