Fixed errors and improved scripts. Players now able to join lobby and start ggame
This commit is contained in:
parent
c4eb2ff33c
commit
7ad364eb7a
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2b8351789fde3394cb1e1fa1f95f7a90
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e651dbb3fbac04af2b8f5abf007ddc23, type: 3}
|
||||
m_Name: NetworkPrefabsList
|
||||
m_EditorClassIdentifier:
|
||||
IsDefault: 0
|
||||
List: []
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3ca514815d13ed84bae5371c002442c4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -2208,19 +2208,7 @@ MonoBehaviour:
|
|||
m_TargetGraphic: {fileID: 1143680571}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 169098378}
|
||||
m_TargetAssemblyTypeName: SteamManager, Project.Scripts
|
||||
m_MethodName: StartGameServer
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
m_Calls: []
|
||||
--- !u!114 &1143680571
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2341,19 +2329,7 @@ MonoBehaviour:
|
|||
m_TargetGraphic: {fileID: 1153985591}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 169098378}
|
||||
m_TargetAssemblyTypeName: SteamManager, Project.Scripts
|
||||
m_MethodName: LeaveLobby
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
m_Calls: []
|
||||
--- !u!114 &1153985591
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -3285,7 +3261,7 @@ MonoBehaviour:
|
|||
m_GameObject: {fileID: 1601178762}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 64b0681bf4afdbd44af7a7c13500d4dc, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: a1d0b1cda8900e34cad917f31b164cf4, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
LocalUiHolder: {fileID: 343728641}
|
||||
|
@ -4126,8 +4102,6 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2015192398}
|
||||
- component: {fileID: 2015192399}
|
||||
- component: {fileID: 2015192400}
|
||||
m_Layer: 5
|
||||
m_Name: InLobbyUI
|
||||
m_TagString: Untagged
|
||||
|
@ -4158,32 +4132,6 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2015192399
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2015192397}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a3e027b9b5a5cde4397048fb5f0418db, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
CopyBtn: {fileID: 2080936077}
|
||||
TextToCopy: {fileID: 1286904157}
|
||||
--- !u!114 &2015192400
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2015192397}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b70b2386d5a93f54aa170082828797c1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &2045910284
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -357,7 +357,7 @@ MonoBehaviour:
|
|||
m_GameObject: {fileID: 162513273}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2d86d25acd5c505479d2c83077d71714, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: bdc01b874dd211d45ae50eade2430b33, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
LocalBtn: {fileID: 1677838174}
|
||||
|
@ -394,8 +394,6 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 72f69be188e3b8b44bacd5ddc0feabef, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
PlayerPrefab: {fileID: 5432701526123299056, guid: 1ed6472f91226d31581e4a3bb89d3aed,
|
||||
type: 3}
|
||||
--- !u!4 &361110445
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -423,7 +421,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GlobalObjectIdHash: 1580236175
|
||||
GlobalObjectIdHash: 322881486
|
||||
AlwaysReplicateAsRoot: 0
|
||||
SynchronizeTransform: 1
|
||||
ActiveSceneSynchronization: 0
|
||||
|
@ -1277,7 +1275,7 @@ MonoBehaviour:
|
|||
PlayerPrefab: {fileID: 0}
|
||||
Prefabs:
|
||||
NetworkPrefabsLists:
|
||||
- {fileID: 11400000, guid: a1f5b87a8958b5e4ca38487bf38691f5, type: 2}
|
||||
- {fileID: 11400000, guid: 3ca514815d13ed84bae5371c002442c4, type: 2}
|
||||
TickRate: 30
|
||||
ClientConnectionBufferTimeout: 10
|
||||
ConnectionApproval: 0
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using Unity.Netcode;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LocalManager : MonoBehaviour
|
||||
|
@ -60,7 +61,11 @@ public class LocalManager : MonoBehaviour
|
|||
public void StartGameServer()
|
||||
{
|
||||
if (!NetworkManager.Singleton.IsHost) return;
|
||||
|
||||
// Gets next scene name
|
||||
int nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1;
|
||||
string nextSceneName = SceneUtility.GetScenePathByBuildIndex(nextSceneIndex);
|
||||
|
||||
NetworkManager.Singleton.SceneManager.LoadScene("Multiplayer", UnityEngine.SceneManagement.LoadSceneMode.Single);
|
||||
NetworkManager.Singleton.SceneManager.LoadScene(nextSceneName, UnityEngine.SceneManagement.LoadSceneMode.Single);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class NetworkManagerUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button hostBtn;
|
||||
[SerializeField] private Button serverBtn;
|
||||
[SerializeField] private Button clientBtn;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
hostBtn.onClick.AddListener(() => {
|
||||
NetworkManager.Singleton.StartHost();
|
||||
});
|
||||
serverBtn.onClick.AddListener(() => {
|
||||
NetworkManager.Singleton.StartServer();
|
||||
});
|
||||
clientBtn.onClick.AddListener(() => {
|
||||
NetworkManager.Singleton.StartClient();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b7f47f18359d7c44b93ef8286f970e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,52 @@
|
|||
using Netcode.Transports.Facepunch;
|
||||
using Steamworks;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Netcode;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NetworkSetup : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button LocalBtn;
|
||||
[SerializeField] private Button SteamBtn;
|
||||
[SerializeField] private GameObject ButtonsHolder;
|
||||
[SerializeField] private GameObject LoadingText;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LocalBtn.onClick.AddListener(OnLocalClicked);
|
||||
SteamBtn.onClick.AddListener(OnSteamClicked);
|
||||
}
|
||||
|
||||
private void OnLocalClicked()
|
||||
{
|
||||
LoadingText.SetActive(true);
|
||||
ButtonsHolder.SetActive(false);
|
||||
|
||||
var transport = NetworkManager.Singleton.gameObject.AddComponent<UnityTransport>();
|
||||
NetworkManager.Singleton.NetworkConfig.NetworkTransport = transport;
|
||||
|
||||
NextScene();
|
||||
}
|
||||
|
||||
private void OnSteamClicked()
|
||||
{
|
||||
LoadingText.SetActive(true);
|
||||
ButtonsHolder.SetActive(false);
|
||||
var transport = NetworkManager.Singleton.gameObject.AddComponent<FacepunchTransport>();
|
||||
NetworkManager.Singleton.NetworkConfig.NetworkTransport = transport;
|
||||
|
||||
NextScene();
|
||||
}
|
||||
|
||||
private void NextScene()
|
||||
{
|
||||
int currentScene = SceneManager.GetActiveScene().buildIndex;
|
||||
SceneManager.LoadScene(++currentScene);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bdc01b874dd211d45ae50eade2430b33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,27 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Netcode;
|
||||
using Unity.Netcode.Transports.UTP;
|
||||
using UnityEngine;
|
||||
|
||||
public class SteamVsLocalUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject LocalUiHolder;
|
||||
[SerializeField] private GameObject SteamUiHolder;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
bool isLocal = NetworkManager.Singleton.NetworkConfig.NetworkTransport is UnityTransport;
|
||||
|
||||
if (isLocal)
|
||||
{
|
||||
LocalUiHolder.SetActive(true);
|
||||
SteamUiHolder.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalUiHolder.SetActive(false);
|
||||
SteamUiHolder.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a1d0b1cda8900e34cad917f31b164cf4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -6,11 +6,11 @@ EditorBuildSettings:
|
|||
serializedVersion: 2
|
||||
m_Scenes:
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/MainMenu.unity
|
||||
guid: 33b308b02cb61b643b15ad93698b00ee
|
||||
path: Assets/Scenes/MultiplayerTestingScenes/Multi-SetupLoad.unity
|
||||
guid: 08b9a73ba5591104ab2ab2ee218a69f0
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/ControlsTutorialScene.unity
|
||||
guid: bc79d5e4c83d675498b09344ca23bde1
|
||||
path: Assets/Scenes/MultiplayerTestingScenes/Multi-MainMenu.unity
|
||||
guid: ab8326cd31eb35d4789ae3ddff98ff0c
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/GameScene.unity
|
||||
guid: 0400e5e5779425c40ba3164b1e0b5b59
|
||||
|
|
Loading…
Reference in New Issue