Auto Play and Skip All buttons
Auto Play and Skip All buttons
Hello Tony, is there integrated function for skipping all lines until the next response menu or conversation end, (Skip All). And Auto play? (When activated, instead of using continue button, after some seconds the next line is played automatically). I need those functions for my dialogue system (Screenshot attached). Thank you in advance!
- Attachments
-
- Screenshot_4.png (719.16 KiB) Viewed 1256 times
Re: Auto Play and Skip All buttons
Hi,
This question comes up on occasion, and there are a few threads that discuss ways to implement it, but I think it's time for an official "how to" thread:
How To: Auto Play / Skip To Player Response
The example in that "how to" skips immediately to the player response menu. You could modify the approach to increase the typing speed and/or briefly flash each line if you prefer.
This question comes up on occasion, and there are a few threads that discuss ways to implement it, but I think it's time for an official "how to" thread:
How To: Auto Play / Skip To Player Response
The example in that "how to" skips immediately to the player response menu. You could modify the approach to increase the typing speed and/or briefly flash each line if you prefer.
Re: Auto Play and Skip All buttons
Awesome, that should do it, thank you Tony, but what about the auto play toggle? Which should disable the continue button, going back to lines skipping after a delay. I searched through the forums and couldn't find a post specific about this, shouldn't be too hard to implement, right? Maybe assigning a function to the button that changes Dialogue System Controller > Subtitle settings > Continue Button > Never would be enough?
Re: Auto Play and Skip All buttons
Hi,
I just updated the post to include Auto Play.
I just updated the post to include Auto Play.
Re: Auto Play and Skip All buttons
Awesome Tony, tested and it works like it should.
I have another question now, I want to hide the continue button UI until the subtitle text has finished 'typewriting' , continue will still have its normal functionality as the button is extended to work anywhere on the screen so if the player clicks while text is still being written, continue will still be triggered, cutting the typewriter animation, so basically I want to display the continue UI after the subtitle is done writing so the player gets a visual clue that this dialogue entry is finished, and clicking will continue the dialogue.
Hiding should go inside the OnDialogueLineStart() function and unhiding inside OnDialogueLineEnd() I suppose? (I dont know the exact names).
I have another question now, I want to hide the continue button UI until the subtitle text has finished 'typewriting' , continue will still have its normal functionality as the button is extended to work anywhere on the screen so if the player clicks while text is still being written, continue will still be triggered, cutting the typewriter animation, so basically I want to display the continue UI after the subtitle is done writing so the player gets a visual clue that this dialogue entry is finished, and clicking will continue the dialogue.
Hiding should go inside the OnDialogueLineStart() function and unhiding inside OnDialogueLineEnd() I suppose? (I dont know the exact names).
Re: Auto Play and Skip All buttons
Hi,
The subtitle text GameObject's typewriter effect has three UnityEvents that you can configure in the inspector. Configure OnCharacter() to deactivate the continue button and OnEnd() to activate it.
The subtitle text GameObject's typewriter effect has three UnityEvents that you can configure in the inspector. Configure OnCharacter() to deactivate the continue button and OnEnd() to activate it.
Re: Auto Play and Skip All buttons
Awesome, thank you again Tony!
There is another small thing, I'm trying to animate the response buttons, but for some reason, maybe the UI Layout element is stopping me from moving the buttons back to their original position. I'm simply moving them a bit to the right when hovered, and moving them back on exit, but as you can see at screenshot_3, they dont go back to where they first appeared at, every button goes to that same position, do you have any idea why this is happening?
Screenshot_1: How it is supposed to look after you leave the button.
2: How it looks when you hover.
3: Where the button actually goes.
Code:
There is another small thing, I'm trying to animate the response buttons, but for some reason, maybe the UI Layout element is stopping me from moving the buttons back to their original position. I'm simply moving them a bit to the right when hovered, and moving them back on exit, but as you can see at screenshot_3, they dont go back to where they first appeared at, every button goes to that same position, do you have any idea why this is happening?
Screenshot_1: How it is supposed to look after you leave the button.
2: How it looks when you hover.
3: Where the button actually goes.
Code:
Code: Select all
public class UIResponseBtHighLight : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler
{
Vector3 originalPos;
RectTransform rectT;
Animator animator;
void OnEnable()
{
//originalPos = this.transform.localPosition; <= will give the same result.
rectT = this.GetComponent<RectTransform>();
animator = this.GetComponent<Animator>();
originalPos = this.rectT.anchoredPosition;
}
public void OnPointerEnter(PointerEventData eventData)
{
Vector3 localPos = new Vector3(transform.localPosition.x + 50, transform.localPosition.y, transform.localPosition.z);
iTween.MoveTo(this.gameObject, iTween.Hash("position", localPos, "islocal", true, "time", 1, "ignoretimescale", true));
//animator.SetBool("isSelected", true);
}
public void OnPointerExit(PointerEventData eventData)
{
iTween.MoveTo(this.gameObject, iTween.Hash("position", originalPos, "islocal", true, "time", 1, "ignoretimescale", true));
//animator.SetBool("isSelected", false);
}
public void OnSelect(BaseEventData eventData)
{
//stuff
}
}
- Attachments
-
- Screenshot_3.png (456.09 KiB) Viewed 1240 times
-
- Screenshot_1.png (456.96 KiB) Viewed 1240 times
-
- Screenshot_2.png (461.05 KiB) Viewed 1240 times
Re: Auto Play and Skip All buttons
Hi,
Can you try tweening the button's RectTransform.anchoredPosition instead of its Transform.position? RectTransform and Transform work in two different coordinate systems. While they sometimes match up, in this case they don't exactly match up to each other.
Can you try tweening the button's RectTransform.anchoredPosition instead of its Transform.position? RectTransform and Transform work in two different coordinate systems. While they sometimes match up, in this case they don't exactly match up to each other.
Re: Auto Play and Skip All buttons
Right, tried
OnPointerExit
{
}
Didn't use the tweening because it seems this version of it doesnt include moving rect transforms with hashable. The moving back animation is not important in my case, so if it simply snapped back into place after OnPointerExit would be okay, but with the function displayed above nothing happens, the buttons stay where the OnPointerEnter tweening animation ends.
OnPointerExit
{
Code: Select all
rectT.anchoredPosition = originalPos;
Didn't use the tweening because it seems this version of it doesnt include moving rect transforms with hashable. The moving back animation is not important in my case, so if it simply snapped back into place after OnPointerExit would be okay, but with the function displayed above nothing happens, the buttons stay where the OnPointerEnter tweening animation ends.
Re: Auto Play and Skip All buttons
Hi,
I'm not sure I follow. Is it working the way you want now?
I haven't used iTween but, assuming it works like DOTween, there's probably a generic tween method that you can use to tween the anchoredPosition without hashable.
I'm not sure I follow. Is it working the way you want now?
I haven't used iTween but, assuming it works like DOTween, there's probably a generic tween method that you can use to tween the anchoredPosition without hashable.