feat: basic online working with relay
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Reset.Core.Tools;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Users;
|
||||
@@ -12,7 +13,17 @@ namespace Reset{
|
||||
public static GameObject Input;
|
||||
public static SessionManager Session;
|
||||
|
||||
public static GameObject Player;
|
||||
private static GameObject player;
|
||||
|
||||
public static GameObject Player{
|
||||
get{ return player; }
|
||||
set{ player = value; }
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void Reset(){
|
||||
player = null;
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void PopulateSceneReferences(){
|
||||
@@ -35,6 +46,17 @@ namespace Reset{
|
||||
playerUser = InputUser.PerformPairingWithDevice(device, playerUser, InputUserPairingOptions.UnpairCurrentDevicesFromUser);
|
||||
}
|
||||
|
||||
public static GameObject FindNewPlayer(){
|
||||
var allPlayers = GameObject.FindGameObjectsWithTag("Player");
|
||||
for (int i = 0; i < allPlayers.Length; i++) {
|
||||
if (allPlayers[i].GetComponent<Player>() && allPlayers[i].GetComponent<NetworkObject>().IsLocalPlayer) {
|
||||
return allPlayers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void RequestNewController(){
|
||||
try {
|
||||
GameObject.Find("Input Selector").GetComponent<InputFinder>().AwaitNewInput();
|
||||
|
||||
Reference in New Issue
Block a user