Updated the UI. Refresh button is disabled for now and multiplayer needs testing. Added quit button.
This commit is contained in:
parent
a8568685ab
commit
bad94ab628
@ -1,5 +1,6 @@
|
||||
using FishNet;
|
||||
using FishNet.Discovery;
|
||||
using FishNet.Managing.Scened;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
@ -10,15 +11,21 @@ using UnityEngine.UI;
|
||||
public class NetworkMenuUI : MonoBehaviour
|
||||
{
|
||||
[Header("UI References")]
|
||||
public Toggle VRToggle;
|
||||
|
||||
public Button startPlayingButton;
|
||||
public Button reloadButton;
|
||||
public Button joinMultiplayerButton;
|
||||
public Transform serverListContainer;
|
||||
public GameObject serverListItemPrefab;
|
||||
public TMP_Text statusText;
|
||||
public Button quitButton;
|
||||
|
||||
[Header("Networking")]
|
||||
public NetworkDiscovery networkDiscovery;
|
||||
public Camera uiCamera; // Optional, disable if connecting
|
||||
public Camera uiCamera;
|
||||
public AudioListener placeholderAudioListener;
|
||||
private bool _useVR;
|
||||
//public Image coverImage;
|
||||
|
||||
private readonly List<IPEndPoint> foundServers = new();
|
||||
@ -28,8 +35,22 @@ public class NetworkMenuUI : MonoBehaviour
|
||||
if (networkDiscovery == null)
|
||||
networkDiscovery = FindObjectOfType<NetworkDiscovery>();
|
||||
|
||||
_useVR = PlayerPrefs.GetInt("UseVR", 0) == 1;
|
||||
VRToggle.isOn = _useVR;
|
||||
|
||||
// React to UI toggle changes
|
||||
VRToggle.onValueChanged.AddListener((isOn) =>
|
||||
{
|
||||
_useVR = isOn;
|
||||
PlayerPrefs.SetInt("UseVR", _useVR ? 1 : 0);
|
||||
PlayerPrefs.Save();
|
||||
Debug.Log($"UseVR set to {_useVR}");
|
||||
});
|
||||
|
||||
startPlayingButton.onClick.AddListener(OnStartPlaying);
|
||||
reloadButton.onClick.AddListener(OnReload);
|
||||
joinMultiplayerButton.onClick.AddListener(OnJoinMultiplayer);
|
||||
quitButton.onClick.AddListener(OnQuit);
|
||||
|
||||
networkDiscovery.ServerFoundCallback += OnServerFound;
|
||||
}
|
||||
@ -40,6 +61,14 @@ public class NetworkMenuUI : MonoBehaviour
|
||||
StartCoroutine(HostAndSearchRoutine());
|
||||
}
|
||||
|
||||
private void OnReload()
|
||||
{
|
||||
|
||||
//UnityEngine.SceneManagement.Scene currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
||||
//UnityEngine.SceneManagement.SceneManager.LoadScene(currentScene.name);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnJoinMultiplayer()
|
||||
{
|
||||
@ -49,6 +78,12 @@ public class NetworkMenuUI : MonoBehaviour
|
||||
networkDiscovery.StartSearchingForServers();
|
||||
}
|
||||
|
||||
private void OnQuit()
|
||||
{
|
||||
Debug.Log("Quitting application");
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
private void OnServerFound(IPEndPoint endPoint)
|
||||
{
|
||||
if (foundServers.Contains(endPoint)) return;
|
||||
@ -61,9 +96,11 @@ public class NetworkMenuUI : MonoBehaviour
|
||||
networkDiscovery.StopSearchingForServers();
|
||||
|
||||
uiCamera.enabled = false;
|
||||
Debug.Log("Disabled placeholder audio source");
|
||||
placeholderAudioListener.enabled = false;
|
||||
//coverImage.gameObject.SetActive(false);
|
||||
|
||||
InstanceFinder.ClientManager.StartConnection("192.168.42.212");
|
||||
InstanceFinder.ClientManager.StartConnection(endPoint.Address.ToString());
|
||||
statusText.text = $"Joined server: {endPoint.Address}";
|
||||
return;
|
||||
}
|
||||
@ -78,6 +115,10 @@ public class NetworkMenuUI : MonoBehaviour
|
||||
{
|
||||
networkDiscovery.StopSearchingForServers();
|
||||
if (uiCamera != null) uiCamera.enabled = false;
|
||||
if (placeholderAudioListener != null) {
|
||||
Debug.Log("Disabled placeholder audio source");
|
||||
placeholderAudioListener.enabled = false;
|
||||
}
|
||||
//coverImage.gameObject.SetActive(false);
|
||||
InstanceFinder.ClientManager.StartConnection(endPoint.Address.ToString());
|
||||
statusText.text = $"Joined server: {endPoint.Address}";
|
||||
@ -121,6 +162,12 @@ public class NetworkMenuUI : MonoBehaviour
|
||||
{
|
||||
var firstServer = foundServers[0];
|
||||
//networkDiscovery.StopAdvertisingServer();
|
||||
if (uiCamera != null) uiCamera.enabled = false;
|
||||
if (placeholderAudioListener != null)
|
||||
{
|
||||
Debug.Log("Disabled placeholder audio source");
|
||||
placeholderAudioListener.enabled = false;
|
||||
}
|
||||
networkDiscovery.StopSearchingForServers();
|
||||
InstanceFinder.ClientManager.StartConnection(firstServer.Address.ToString());
|
||||
statusText.text = $"Joined server: {firstServer.Address}";
|
||||
|
BIN
Assets/_PROJECT/Components/Overlay UI/UI refresh icon.png
(Stored with Git LFS)
Normal file
BIN
Assets/_PROJECT/Components/Overlay UI/UI refresh icon.png
(Stored with Git LFS)
Normal file
Binary file not shown.
160
Assets/_PROJECT/Components/Overlay UI/UI refresh icon.png.meta
Normal file
160
Assets/_PROJECT/Components/Overlay UI/UI refresh icon.png.meta
Normal file
@ -0,0 +1,160 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d929b603389e5b41a32bc6ea11e38ee
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Windows Store Apps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/_PROJECT/Scenes/DeltaBuilding_base.unity
(Stored with Git LFS)
BIN
Assets/_PROJECT/Scenes/DeltaBuilding_base.unity
(Stored with Git LFS)
Binary file not shown.
@ -8,6 +8,10 @@
|
||||
"name": "Dabest",
|
||||
"score": 407.0
|
||||
},
|
||||
{
|
||||
"name": "henri",
|
||||
"score": 333.0
|
||||
},
|
||||
{
|
||||
"name": "destro",
|
||||
"score": 332.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user