- Home /
Question by
bossic · Apr 19, 2020 at 04:54 PM ·
c#scripting problemscrollviewswipe
Swipe incorrectly working
Hey there. I have a problem: When I swipe on Unity Editor everything is ok. But when I swipe on an android phone, then AudioSource.Time is going to end in same time.
public class SwipeManager : MonoBehaviour, IBeginDragHandler, IDragHandler
{
// public AudioSource AS;
public Scrollbar SB;
public float WaitWhile=0.1f, VoiceMomentChange = 5f;
public VoiceManager VM;
public AudioSource VoiceSource;
bool isEnd=false;
public Text text;
//punlic float f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (SB.value <= 0.0001)
{
isEnd = true;
}
}
public void OnBeginDrag(PointerEventData eventData)
{
if ((Mathf.Abs(eventData.delta.y)) > (Mathf.Abs(eventData.delta.x)))
{
// if (eventData.delta.y > 0)
// {
// Debug.Log("+Y");
StartCoroutine(WaitForWhile(eventData));
// VoiceSource.time += 5f;
//}
// else
//{
// Debug.Log("-Y");
// StartCoroutine(WaitForWhile(eventData));
// VoiceSource.time -= 5f;
//}
}
}
public void OnDrag(PointerEventData eventData)
{
}
public IEnumerator WaitForWhile(PointerEventData eventData)
{
while (eventData.delta.y > 0)
{
VoiceSource.time += VoiceMomentChange;
// f = eventData.delta.y;
text.text = eventData.delta.y.ToString();
yield return new WaitForSeconds(WaitWhile);
}
while (eventData.delta.y < 0)
{
if (isEnd == true && VoiceSource.isPlaying==false)
{
VoiceSource.Play();
VoiceSource.time = VM.timeOfVoice- VoiceMomentChange;
isEnd = false;
}
VoiceSource.time -= VoiceMomentChange;
if (SB.value>=0.96)
VoiceSource.time=0;
VoiceSource.time += VoiceMomentChange;
// f = eventData.delta.y;
text.text = eventData.delta.y.ToString();
yield return new WaitForSeconds(WaitWhile);
}
}
}
Thank you for help.
Comment