|
|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.InputSystem;
- using UnityEngine.UI;
-
- public class PlayerJoinIcon : MonoBehaviour
- {
- [SerializeField]
- private Image m_apron;
-
-
- private PlayerData m_data;
- private Vector3 m_startingScale;
-
-
- private void OnEnable()
- {
- m_startingScale = transform.localScale;
- Debug.Log("New player awake");
- if (m_data != null)
- {
- m_data.Input.currentActionMap.FindAction("Ping").started += OnPlayerPing;
- m_data.Input.currentActionMap.FindAction("Ping").canceled += OnPlayerPing;
- }
-
-
- }
-
- private void OnDisable()
- {
- if (m_data != null)
- {
- m_data.Input.currentActionMap.FindAction("Ping").started -= OnPlayerPing;
- m_data.Input.currentActionMap.FindAction("Ping").canceled -= OnPlayerPing;
- }
- }
-
- public void Initialise(PlayerData data)
- {
- Debug.Log("Initialised new Player");
- m_data = data;
- m_apron.color = data.Color;
- }
-
- public void OnPlayerPing(InputAction.CallbackContext args)
- {
- Debug.Log($"Ping: {args.phase}");
- if (args.phase == InputActionPhase.Started)
- transform.localScale = m_startingScale * 1.1f;
- else if (args.phase == InputActionPhase.Canceled)
- transform.localScale = m_startingScale;
- }
-
-
- }
|