Hello,
I have working quiz template from asset store. There is two button correct and false buttons. Everything is working fine. I need simulate button click with playmaker, because i want to do swipe action (no need press button). How use swipe, get key i know how to do.
Example right swipe = pressing true button, swipe left = pressing false buttonI tried many variations with call method, set property, send message anything dont working. Easiest way i think is simulate button press. Why there is no playmaker action, choose button, make condition and button is pressed?

because i think couple same stories here on forum with no luck...
here is main script and button script. I already tried many things and no luck

Maybe you can help me? Thanks in advance.
Main script:
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Assertions;
namespace TriviaQuizKit
{
/// <summary>
/// The user interface to display with true or false questions.
/// </summary>
public class TrueFalseQuestionUi : QuestionUi
{
public TextMeshProUGUI QuestionText;
public Image QuestionImage;
public List<FlatButton> AnswerButtons;
public Sprite DefaultAnswerSprite;
public Sprite CorrectAnswerSprite;
public Sprite WrongAnswerSprite;
private int correctAnswerIndex;
private int numWrongAnswers;
public override void OnQuestionLoaded(GameScreen gameScreen, BaseQuestion question)
{
var trueFalseQuestion = question as TrueFalseQuestion;
Assert.IsNotNull(trueFalseQuestion);
QuestionText.text = trueFalseQuestion.Question;
if (trueFalseQuestion.Image != null)
{
QuestionImage.sprite = trueFalseQuestion.Image;
QuestionImage.preserveAspect = true;
}
correctAnswerIndex = trueFalseQuestion.IsTrue ? 0 : 1;
AnswerButtons[0].OnPressedEvent.RemoveAllListeners();
AnswerButtons[1].OnPressedEvent.RemoveAllListeners();
AnswerButtons[0].OnPressedEvent.AddListener(() => { gameScreen.OnPlayerAnswered(0); });
AnswerButtons[1].OnPressedEvent.AddListener(() => { gameScreen.OnPlayerAnswered(1); });
}
public override bool OnQuestionAnswered(int answerIdx)
{
var correct = answerIdx == correctAnswerIndex;
if (correct)
{
HighlightCorrectAnswer();
Debug.Log("paspaude3");
}
else
{
HighlightCorrectAnswer();
HighlightWrongAnswer(answerIdx);
Debug.Log("paspaude4");
}
AnswerButtons[0].OnPressedEvent.RemoveAllListeners();
AnswerButtons[1].OnPressedEvent.RemoveAllListeners();
return correct;
}
public override void HighlightCorrectAnswer ()
{
AnswerButtons[correctAnswerIndex].GetComponent<Image>().sprite = CorrectAnswerSprite;
}
public override void HighlightWrongAnswer(int answerIdx)
{
AnswerButtons[answerIdx].GetComponent<Image>().sprite = WrongAnswerSprite;
}
public override void LockUi()
{
foreach (var button in AnswerButtons)
{
button.OnPressedEvent.RemoveAllListeners();
}
}
public override void UnlockUi()
{
foreach (var button in AnswerButtons)
{
button.GetComponent<Image>().sprite = DefaultAnswerSprite;
}
}
public override void OnSelectButtonPressed()
{
Debug.Log("kazkas vyksta");
}
}
}
And flat button script
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace TriviaQuizKit
{
/// <summary>
/// Button class used in the kit. It provides a subtle 'pressed' animation effect when clicked/touched.
/// </summary>
public class FlatButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
{
public float PressedDisplacement = 5f;
public TextMeshProUGUI Text;
public UnityEvent OnPressedEvent;
private bool isMouseInside;
public void OnPointerEnter(PointerEventData pointerEventData)
{
isMouseInside = true;
}
public void OnPointerExit(PointerEventData pointerEventData)
{
isMouseInside = false;
}
public void OnPointerDown(PointerEventData pointerEventData)
{
var rectTransform = GetComponent<RectTransform>();
var newPos = rectTransform.anchoredPosition;
newPos.y -= PressedDisplacement;
rectTransform.anchoredPosition = newPos;
}
public void OnPointerUp(PointerEventData pointerEventData)
{
var rectTransform = GetComponent<RectTransform>();
var newPos = rectTransform.anchoredPosition;
newPos.y += PressedDisplacement;
rectTransform.anchoredPosition = newPos;
if (isMouseInside)
{
Debug.Log("spaudziama");
OnPressedEvent.Invoke();
}
}
}
}