-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a3112c
commit cda62f9
Showing
9 changed files
with
147 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using UnityEngine; | ||
using UnityEngine.EventSystems; | ||
|
||
namespace Unity.VideoHelper | ||
{ | ||
/// <summary> | ||
/// Forwards clicks when the pointer is pressed. | ||
/// Use <see cref="ClickRouter"/> for forwarding upon release of the pointer. | ||
/// </summary> | ||
/// <remarks> | ||
/// Use this component on GameObjects that initiate fullscreen in WebGL builds. | ||
/// There is a browser limitation that ensures that you can only go fullscreen when a user clicks the page. | ||
/// Not using <see cref="OnPointerDown(PointerEventData)"/> requires another click for Unity to go into fullscreen. | ||
/// </remarks> | ||
public class DirectClickRouter : ClickRouter | ||
{ | ||
private float lastClickTime = 0f; | ||
private const float clickInterval = 0.3f; | ||
|
||
public override void OnPointerClick(PointerEventData eventData) | ||
{ | ||
// do nothing | ||
} | ||
|
||
public override void OnPointerDown(PointerEventData eventData) | ||
{ | ||
if (lastClickTime + clickInterval > Time.time) | ||
OnDoubleClick.Invoke(); | ||
else | ||
OnClick.Invoke(); | ||
|
||
lastClickTime = Time.time; | ||
} | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
Assets/VideoPlayer Helper/Scripts/DirectClickRouter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.