Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class PlayerJoystickManager : MonoBehaviour {
- [SerializeField] int base_p1 = -1;
- [SerializeField] int base_p2 = -1;
- [HideInInspector] public bool ready;
- PlayerInputInfo player1_info, player2_info;
- static public PlayerJoystickManager instance;
- void Awake () {
- if (!instance) {
- instance = this;
- DontDestroyOnLoad(this);
- if (base_p1 > -1) set_player_info(1, base_p1);
- if (base_p2 > -1) set_player_info(2, base_p2);
- } else {
- Destroy(gameObject);
- }
- }
- public void set_player_info(int player_id, int controller_id) {
- if (player_id == 1) {
- if(controller_id < 0) {
- player1_info = null;
- return;
- }
- player1_info = new PlayerInputInfo();
- player1_info.set_inputs(player_id, controller_id);
- ready = true;
- } else {
- if (controller_id < 0) {
- player2_info = null;
- return;
- }
- player2_info = new PlayerInputInfo();
- player2_info.set_inputs(player_id, controller_id);
- }
- }
- public PlayerInputInfo get_player_info(int player_id) {
- if (player_id == 1)
- return player1_info;
- else
- return player2_info;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment