Je suis en train de commencer le code et voilà que je bute à mon premier essai en solo... Je vous expose mon problème:j'ai un script A, qui me sert a repéré un long clic, et un script B, à qui je donnerais des instructions au personnage en fonction du clic long. Seulement voilà: je n'arrive pas à faire passer les informations grâce au propreties!
J'aimerais vraiment savoir ce qui bloque...
ScriptA
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KLongClick : MonoBehaviour
{
private float startTime, endTime;
bool _longClick = false;
#region properties
// envoyer l'info du _longClick
public bool LongClick
{
get
{
return _longClick;
Debug.Log("Yes" + _longClick);
}
}
#endregion
#region Method
void Start()
{
startTime = 0f;
endTime = 0f;
}
void Update() {
if (Input.GetMouseButtonDown(0))
startTime= Time.time;
if (Input.GetMouseButtonUp(0))
endTime = Time.time;
if ( endTime - startTime > 0.1f)
{
startTime = 0f;
endTime = 0f;
_longClick = true;
Debug.Log("Long Click " + _longClick);
}
if (!Input.GetMouseButtonUp(0))
{
_longClick = false;
Debug.Log("Long Click else " + _longClick);
}
}
#endregion
}
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Perso : MonoBehaviour
{
KLongClick longclick = new KLongClick();
bool _longClick = true;
void Start()
{
}
// Update is called once per frame //
void Update()
{
_longClick = longclick.LongClick;
Debug.Log("blabla " + _longClick);
}
}
Alors merci à ceux qui m'aiderons et bonne après-midi