Revert "Update input bug"

This reverts commit 98c6a0edb0.
dev-ali
Ali Sharoz 2 months ago
parent 98c6a0edb0
commit 8f28b4cd51

@ -16,7 +16,7 @@ MonoBehaviour:
AppIdFusion: d1a1c822-ada0-47af-95d6-d64a4283f68d AppIdFusion: d1a1c822-ada0-47af-95d6-d64a4283f68d
AppIdChat: AppIdChat:
AppIdVoice: AppIdVoice:
AppVersion: 1.0 AppVersion:
UseNameServer: 1 UseNameServer: 1
FixedRegion: FixedRegion:
Server: Server:

@ -7,7 +7,7 @@ PhysicMaterial:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Friction m_Name: Friction
dynamicFriction: 0.06998743 dynamicFriction: 0.069989614
staticFriction: 1 staticFriction: 1
bounciness: 0.3 bounciness: 0.3
frictionCombine: 3 frictionCombine: 3

@ -2859,13 +2859,13 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1868736288} m_GameObject: {fileID: 1868736288}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.6439234, z: 0, w: 0.76509005} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -48.340305, y: -17.914295, z: -5.1727653} m_LocalPosition: {x: -48.340305, y: -17.914295, z: -5.1727653}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 80.17, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1897337258 --- !u!1 &1897337258
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3249,13 +3249,13 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1928440682} m_GameObject: {fileID: 1928440682}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.6477876, z: 0, w: 0.7618211} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -48.340305, y: -17.914295, z: 1.85} m_LocalPosition: {x: -48.340305, y: -17.914295, z: 1.85}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 80.75, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2062866431 --- !u!1 &2062866431
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -337,7 +337,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.00019626642, y: 0} m_AnchoredPosition: {x: 0.00023456286, y: 0}
m_SizeDelta: {x: -943, y: 0} m_SizeDelta: {x: -943, y: 0}
m_Pivot: {x: 0, y: 1} m_Pivot: {x: 0, y: 1}
--- !u!114 &54820778 --- !u!114 &54820778
@ -4018,6 +4018,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1319984346} - component: {fileID: 1319984346}
- component: {fileID: 1319984349}
- component: {fileID: 1319984348} - component: {fileID: 1319984348}
m_Layer: 0 m_Layer: 0
m_Name: NetworkManager m_Name: NetworkManager
@ -4061,6 +4062,18 @@ MonoBehaviour:
waitingText: {fileID: 805019539} waitingText: {fileID: 805019539}
playerPrefab: playerPrefab:
RawGuidValue: b7ef0b21caef7df4fbaf32ff73da212f RawGuidValue: b7ef0b21caef7df4fbaf32ff73da212f
--- !u!114 &1319984349
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1319984343}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 14040d85e2892f242981c2fe3079b3de, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1325907563 --- !u!1 &1325907563
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6052,7 +6065,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 2038445526} - component: {fileID: 2038445526}
- component: {fileID: 2038445525} - component: {fileID: 2038445525}
- component: {fileID: 2038445527}
m_Layer: 0 m_Layer: 0
m_Name: NetworkRunner m_Name: NetworkRunner
m_TagString: Untagged m_TagString: Untagged
@ -6087,18 +6099,6 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2038445527
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2038445524}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 14040d85e2892f242981c2fe3079b3de, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &2082204556 --- !u!1 &2082204556
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -8,9 +8,6 @@ using UnityEngine.SceneManagement;
using TMPro; using TMPro;
using UnityEngine.UI; using UnityEngine.UI;
using System.Linq; using System.Linq;
using Fusion.Photon.Realtime;
using static Unity.Collections.Unicode;
public class FusionLauncher : MonoBehaviour, INetworkRunnerCallbacks public class FusionLauncher : MonoBehaviour, INetworkRunnerCallbacks
{ {
@ -66,7 +63,6 @@ public class FusionLauncher : MonoBehaviour, INetworkRunnerCallbacks
IEnumerator AutoRefreshLobbyList() IEnumerator AutoRefreshLobbyList()
{ {
yield return new WaitForSeconds(2f);
while (true) while (true)
{ {
RefreshLobbyList(); RefreshLobbyList();
@ -116,20 +112,31 @@ public class FusionLauncher : MonoBehaviour, INetworkRunnerCallbacks
// —————— RESET / CREATE FRESH RUNNER —————— // —————— RESET / CREATE FRESH RUNNER ——————
private async Task EnsureFreshRunner() private async Task EnsureFreshRunner()
{ {
// … your existing shutdown/destroy logic … // Reset flags
playerCount = 0;
gameplayLoaded = false;
connectedToServer = false;
// If an old runner exists & is running, shut it down & destroy its GO
if (runner != null && runner.IsRunning)
{
await runner.Shutdown();
Destroy(runner.gameObject);
}
// Stop auto-refresh while we rebuild
if (refreshCoroutine != null)
{
StopCoroutine(refreshCoroutine);
refreshCoroutine = null;
}
// Make brand-new runner GameObject
var go = new GameObject("NetworkRunnerGO"); var go = new GameObject("NetworkRunnerGO");
DontDestroyOnLoad(go); DontDestroyOnLoad(go); // keep it alive across scenes
// 1) Add the runner
runner = go.AddComponent<NetworkRunner>(); runner = go.AddComponent<NetworkRunner>();
runner.ProvideInput = true; runner.ProvideInput = true;
// 2) Add *and* register your provider
var inputProv = go.AddComponent<FusionInputProvider>();
runner.AddCallbacks(inputProv);
// 3) If you still want FusionLauncher callbacks:
runner.AddCallbacks(this); runner.AddCallbacks(this);
} }
@ -139,29 +146,33 @@ public class FusionLauncher : MonoBehaviour, INetworkRunnerCallbacks
var name = lobbyNameInput.text.Trim(); var name = lobbyNameInput.text.Trim();
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
Debug.LogWarning("[Host] Empty lobby name, not creating."); Debug.LogWarning("Empty lobby name!");
return; return;
} }
// Tear down browse runner & spawn a fresh one
await EnsureFreshRunner(); await EnsureFreshRunner();
var sceneRef = SceneRef.FromIndex(SceneManager.GetActiveScene().buildIndex);
var res = await runner.StartGame(new StartGameArgs() var res = await runner.StartGame(new StartGameArgs()
{ {
GameMode = GameMode.Host, GameMode = GameMode.Host,
SessionName = name, SessionName = name,
PlayerCount = maxPlayers, PlayerCount = maxPlayers,
Scene = SceneRef.FromIndex(SceneManager.GetActiveScene().buildIndex), Scene = sceneRef,
SceneManager = runner.gameObject.AddComponent<NetworkSceneManagerDefault>() SceneManager = runner.gameObject.AddComponent<NetworkSceneManagerDefault>()
}); });
if (res.Ok) if (res.Ok)
{ {
Debug.Log($"✔ Hosted Lobby '{name}'");
lobbyUI.SetActive(false); lobbyUI.SetActive(false);
waitingText.text = "Waiting for player 2…"; waitingText.text = "Waiting for player 2…";
waitingText.gameObject.SetActive(true); waitingText.gameObject.SetActive(true);
} }
else else
{ {
Debug.LogError($"[Host] ✖ Host failed: {res.ShutdownReason}"); Debug.LogError($"✖ Host failed: {res.ShutdownReason}");
} }
} }
@ -192,40 +203,14 @@ public class FusionLauncher : MonoBehaviour, INetworkRunnerCallbacks
} }
} }
private bool isJoiningLobby = false; // —————— REFRESH LOBBY LIST ——————
[ContextMenu("RefreshLobbyList")]
public void RefreshLobbyList() public void RefreshLobbyList()
{ {
// 1) ensure runner exists & is running if (!connectedToServer) return;
if (runner == null || !runner.IsRunning) //sessionListUIHandler.ClearList();
return; runner.JoinSessionLobby(SessionLobby.ClientServer);
// 2) dont spam JoinLobby if one is in flight
if (isJoiningLobby)
return;
// 3) only once were cloud-ready
if (!runner.IsCloudReady)
{
Debug.Log("[Client] skipping Refresh: not yet cloud-ready");
return;
} }
// 4) now we can safely join the lobby
isJoiningLobby = true;
runner.JoinSessionLobby(SessionLobby.ClientServer)
.ContinueWith(_ => isJoiningLobby = false);
} // —————— REFRESH LOBBY LIST ——————
//public void RefreshLobbyList()
//{
// if (!connectedToServer) return;
// ////sessionListUIHandler.ClearList();
// runner.JoinSessionLobby(SessionLobby.ClientServer);
// //runner.JoinSessionLobby(SessionLobby.Shared);
//}
// —————— FUSION CALLBACKS —————— // —————— FUSION CALLBACKS ——————
public void OnConnectedToServer(NetworkRunner r) public void OnConnectedToServer(NetworkRunner r)
{ {

Loading…
Cancel
Save