-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
somewhat hacky but it works on mobile
- Loading branch information
Showing
5 changed files
with
152 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Netherlands3D.Events; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.EventSystems; | ||
|
||
namespace Netherlands3D.Twin | ||
{ | ||
public class MobileButton : MonoBehaviour, IPointerUpHandler, IPointerDownHandler | ||
{ | ||
private RaceController controller; | ||
private bool isPressed = false; | ||
public float moveValue = 0; | ||
|
||
private void Start() | ||
{ | ||
controller = FindObjectOfType<RaceController>(); | ||
} | ||
|
||
public void OnPointerDown(PointerEventData eventData) | ||
{ | ||
isPressed = true; | ||
} | ||
|
||
public void OnPointerUp(PointerEventData eventData) | ||
{ | ||
isPressed = false; | ||
} | ||
|
||
private void Update() | ||
{ | ||
if (controller != null && isPressed) | ||
{ | ||
controller.MoveHorizontally(moveValue); | ||
} | ||
} | ||
} | ||
} |
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