Skip to content

Commit

Permalink
feat(Generator): 実験的にジェネレータのクリック時とタッチ時の挙動を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
IwamotoKakeru committed May 11, 2024
1 parent ef95cbf commit 9277950
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Assets/Scripts/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// キャラクターを生成する
/// </summary>
/// 実装:岩本
public class Generator : MonoBehaviour, IPointerDownHandler
public class Generator : MonoBehaviour, IPointerDownHandler, IPointerClickHandler
{
public GameObject generateObject;

Expand All @@ -33,6 +33,8 @@ public class Generator : MonoBehaviour, IPointerDownHandler
private bool isGenerating = false;
private Vector3 generateLocalPos = new Vector3(0, -1.0f, 0);

private bool touchableDevice = false;

/// <summary>
/// オブジェクトプールにオブジェクトを非アクティブにして追加
/// </summary>
Expand Down Expand Up @@ -77,15 +79,32 @@ void Start()
numDisplay.DisplayInt(maxGenerateNum);
audioSource = GetComponent<AudioSource>();
hoverComponent = GetComponent<Hover>();

#if UNITY_WEBGL && !UNITY_EDITOR
touchableDevice = Utility.WebGL.CheckTouchDevice();
#endif
}
// タッチされた際の挙動
void IPointerClickHandler.OnPointerClick(PointerEventData pointerEventData)
{
#if UNITY_WEBGL && !UNITY_EDITOR
if (pointerEventData.button == PointerEventData.InputButton.Left && generatedNum < maxGenerateNum)
StartCoroutine(GenerateCoroutine());
#endif
}

// クリックされた際の挙動
void IPointerDownHandler.OnPointerDown(PointerEventData pointerEventData)
{
if (touchableDevice)
{
return;
}
if (pointerEventData.button == PointerEventData.InputButton.Left && generatedNum < maxGenerateNum)
StartCoroutine(GenerateCoroutine());
}


private IEnumerator GenerateCoroutine()
{
// 2重で生成することを防ぐ
Expand Down

0 comments on commit 9277950

Please sign in to comment.