aha
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30978876e2c422c41a7a1bc2b7bb280f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1128
Assets/Mirror/Examples/EdgegapLobby/EdgegapLobbyTanks.unity
Normal file
1128
Assets/Mirror/Examples/EdgegapLobby/EdgegapLobbyTanks.unity
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dbbfee253d4c6e4d915cb88674ec680
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/EdgegapLobbyTanks.unity
|
||||
uploadId: 736421
|
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 810426bd131b7fd4dbf1366398224990
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 23800000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/EdgegapLobbyTanks/NavMesh.asset
|
||||
uploadId: 736421
|
8
Assets/Mirror/Examples/EdgegapLobby/Prefabs.meta
Normal file
8
Assets/Mirror/Examples/EdgegapLobby/Prefabs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 776ba2248d912ad4b839e39448ad4a9c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
4617
Assets/Mirror/Examples/EdgegapLobby/Prefabs/LobbyUI.prefab
Normal file
4617
Assets/Mirror/Examples/EdgegapLobby/Prefabs/LobbyUI.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebc1436948da70b4abbf74f58106c318
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/Prefabs/LobbyUI.prefab
|
||||
uploadId: 736421
|
294
Assets/Mirror/Examples/EdgegapLobby/Prefabs/LobbyUIEntry.prefab
Normal file
294
Assets/Mirror/Examples/EdgegapLobby/Prefabs/LobbyUIEntry.prefab
Normal file
@ -0,0 +1,294 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1861598604008055398
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1861598604008055397}
|
||||
- component: {fileID: 1861598604008055395}
|
||||
- component: {fileID: 1861598604008055396}
|
||||
m_Layer: 5
|
||||
m_Name: PlayerCount
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1861598604008055397
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604008055398}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1861598604614510503}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.6, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0.000030517578}
|
||||
m_SizeDelta: {x: -30, y: 0}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &1861598604008055395
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604008055398}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1861598604008055396
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604008055398}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 46
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 4
|
||||
m_MaxSize: 46
|
||||
m_Alignment: 5
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 1/5
|
||||
--- !u!1 &1861598604367147692
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1861598604367147691}
|
||||
- component: {fileID: 1861598604367147689}
|
||||
- component: {fileID: 1861598604367147690}
|
||||
m_Layer: 5
|
||||
m_Name: Name
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1861598604367147691
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604367147692}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1861598604614510503}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0.6, y: 1}
|
||||
m_AnchoredPosition: {x: 30, y: 0.000030517578}
|
||||
m_SizeDelta: {x: -30, y: 0}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &1861598604367147689
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604367147692}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1861598604367147690
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604367147692}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 46
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 4
|
||||
m_MaxSize: 46
|
||||
m_Alignment: 3
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: A long lobby name
|
||||
--- !u!1 &1861598604614510488
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1861598604614510503}
|
||||
- component: {fileID: 1861598604614510500}
|
||||
- component: {fileID: 1861598604614510501}
|
||||
- component: {fileID: 1861598604614510502}
|
||||
- component: {fileID: 827505188}
|
||||
m_Layer: 5
|
||||
m_Name: LobbyUIEntry
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1861598604614510503
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604614510488}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1861598604367147691}
|
||||
- {fileID: 1861598604008055397}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &1861598604614510500
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604614510488}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1861598604614510501
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604614510488}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &1861598604614510502
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604614510488}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 1861598604614510501}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &827505188
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861598604614510488}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9bd3228b44c0a7e478964d95c512cebf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
JoinButton: {fileID: 1861598604614510502}
|
||||
Name: {fileID: 1861598604367147690}
|
||||
PlayerCount: {fileID: 1861598604008055396}
|
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ad36d24bb59d094dbf84bf5bbbdd1c6
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/Prefabs/LobbyUIEntry.prefab
|
||||
uploadId: 736421
|
8
Assets/Mirror/Examples/EdgegapLobby/Scripts.meta
Normal file
8
Assets/Mirror/Examples/EdgegapLobby/Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db78997560ea9e94fafeeca27eb3e4f0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyCreate.cs
Normal file
54
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyCreate.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using Edgegap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Mirror.Examples.EdgegapLobby
|
||||
{
|
||||
public class UILobbyCreate : MonoBehaviour
|
||||
{
|
||||
public UILobbyList List;
|
||||
public Button CancelButton;
|
||||
public InputField LobbyName;
|
||||
public Text SlotCount;
|
||||
public Slider SlotSlider;
|
||||
public Button HostButton;
|
||||
public Button ServerButton;
|
||||
private EdgegapLobbyKcpTransport _transport => (EdgegapLobbyKcpTransport)NetworkManager.singleton.transport;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
ValidateName();
|
||||
LobbyName.onValueChanged.AddListener(_ =>
|
||||
{
|
||||
ValidateName();
|
||||
});
|
||||
CancelButton.onClick.AddListener(() =>
|
||||
{
|
||||
List.gameObject.SetActive(true);
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
SlotSlider.onValueChanged.AddListener(arg0 =>
|
||||
{
|
||||
SlotCount.text = ((int)arg0).ToString();
|
||||
});
|
||||
HostButton.onClick.AddListener(() =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
_transport.SetServerLobbyParams(LobbyName.text, (int)SlotSlider.value);
|
||||
NetworkManager.singleton.StartHost();
|
||||
});
|
||||
ServerButton.onClick.AddListener(() =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
_transport.SetServerLobbyParams(LobbyName.text, (int)SlotSlider.value);
|
||||
NetworkManager.singleton.StartServer();
|
||||
});
|
||||
}
|
||||
void ValidateName()
|
||||
{
|
||||
bool valid = !string.IsNullOrWhiteSpace(LobbyName.text);
|
||||
HostButton.interactable = valid;
|
||||
ServerButton.interactable = valid;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d48c41753254160ac6a02c9585880f0
|
||||
timeCreated: 1709967491
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyCreate.cs
|
||||
uploadId: 736421
|
37
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyEntry.cs
Normal file
37
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyEntry.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Edgegap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Mirror.Examples.EdgegapLobby
|
||||
{
|
||||
public class UILobbyEntry : MonoBehaviour
|
||||
{
|
||||
public Button JoinButton;
|
||||
public Text Name;
|
||||
public Text PlayerCount;
|
||||
|
||||
private LobbyBrief _lobby;
|
||||
private UILobbyList _list;
|
||||
private void Awake()
|
||||
{
|
||||
JoinButton.onClick.AddListener(() =>
|
||||
{
|
||||
_list.Join(_lobby);
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(UILobbyList list, LobbyBrief lobby, bool active = true)
|
||||
{
|
||||
gameObject.SetActive(active && lobby.is_joinable);
|
||||
JoinButton.interactable = lobby.available_slots > 0;
|
||||
_list = list;
|
||||
_lobby = lobby;
|
||||
Name.text = lobby.name;
|
||||
PlayerCount.text = $"{lobby.player_count}/{lobby.capacity}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bd3228b44c0a7e478964d95c512cebf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyEntry.cs
|
||||
uploadId: 736421
|
91
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyList.cs
Normal file
91
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyList.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Edgegap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
namespace Mirror.Examples.EdgegapLobby
|
||||
{
|
||||
public class UILobbyList : MonoBehaviour
|
||||
{
|
||||
public UILobbyCreate Create;
|
||||
|
||||
public GameObject EntryPrefab;
|
||||
public Transform LobbyContent;
|
||||
public GameObject Loading;
|
||||
public Button RefreshButton;
|
||||
public InputField SearchInput;
|
||||
public Button CreateButton;
|
||||
public Text Error;
|
||||
private List<UILobbyEntry> _entries = new List<UILobbyEntry>();
|
||||
|
||||
private EdgegapLobbyKcpTransport _transport => (EdgegapLobbyKcpTransport)NetworkManager.singleton.transport;
|
||||
private void Awake()
|
||||
{
|
||||
SearchInput.onValueChanged.AddListener(arg0 =>
|
||||
{
|
||||
SetLobbies(_transport.Api.Lobbies);
|
||||
});
|
||||
RefreshButton.onClick.AddListener(Refresh);
|
||||
CreateButton.onClick.AddListener(() =>
|
||||
{
|
||||
Create.gameObject.SetActive(true);
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
Loading.SetActive(true);
|
||||
_transport.Api.RefreshLobbies(SetLobbies, s =>
|
||||
{
|
||||
Error.text = s;
|
||||
Loading.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void Join(LobbyBrief lobby)
|
||||
{
|
||||
NetworkManager.singleton.networkAddress = lobby.lobby_id;
|
||||
NetworkManager.singleton.StartClient();
|
||||
}
|
||||
|
||||
public void SetLobbies(LobbyBrief[] lobbies)
|
||||
{
|
||||
Loading.SetActive(false);
|
||||
Error.text = "";
|
||||
// Create enough entries
|
||||
for (int i = _entries.Count; i < lobbies.Length; i++)
|
||||
{
|
||||
var go = Instantiate(EntryPrefab, LobbyContent);
|
||||
_entries.Add(go.GetComponent<UILobbyEntry>());
|
||||
}
|
||||
|
||||
// Update entries
|
||||
var searchText = SearchInput.text;
|
||||
for (int i = 0; i < lobbies.Length; i++)
|
||||
{
|
||||
_entries[i].Init(
|
||||
this,
|
||||
lobbies[i],
|
||||
// search filter
|
||||
searchText.Length == 0 ||
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
lobbies[i].name.Contains(searchText, StringComparison.InvariantCultureIgnoreCase)
|
||||
#else
|
||||
lobbies[i].name.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase) >= 0
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
// hide entries that are too many
|
||||
for (int i = lobbies.Length; i < _entries.Count; i++)
|
||||
{
|
||||
_entries[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5e5ad322f314077a66f889b58485188
|
||||
timeCreated: 1709962378
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyList.cs
|
||||
uploadId: 736421
|
121
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyStatus.cs
Normal file
121
Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyStatus.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using Edgegap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
namespace Mirror.Examples.EdgegapLobby
|
||||
{
|
||||
public class UILobbyStatus : MonoBehaviour
|
||||
{
|
||||
public GameObject[] ShowDisconnected;
|
||||
public GameObject[] ShowServer;
|
||||
public GameObject[] ShowHost;
|
||||
public GameObject[] ShowClient;
|
||||
public Button StopServer;
|
||||
public Button StopHost;
|
||||
public Button StopClient;
|
||||
public Text StatusText;
|
||||
private Status _status;
|
||||
private EdgegapLobbyKcpTransport _transport;
|
||||
enum Status
|
||||
{
|
||||
Offline,
|
||||
Server,
|
||||
Host,
|
||||
Client
|
||||
}
|
||||
void Awake()
|
||||
{
|
||||
Refresh();
|
||||
StopServer.onClick.AddListener(() =>
|
||||
{
|
||||
NetworkManager.singleton.StopServer();
|
||||
});
|
||||
StopHost.onClick.AddListener(() =>
|
||||
{
|
||||
NetworkManager.singleton.StopHost();
|
||||
});
|
||||
StopClient.onClick.AddListener(() =>
|
||||
{
|
||||
NetworkManager.singleton.StopClient();
|
||||
});
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
_transport = (EdgegapLobbyKcpTransport)NetworkManager.singleton.transport;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
var status = GetStatus();
|
||||
if (_status != status)
|
||||
{
|
||||
_status = status;
|
||||
Refresh();
|
||||
}
|
||||
if (_transport)
|
||||
{
|
||||
StatusText.text = _transport.Status.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusText.text = "";
|
||||
}
|
||||
}
|
||||
private void Refresh()
|
||||
{
|
||||
switch (_status)
|
||||
{
|
||||
|
||||
case Status.Offline:
|
||||
SetUI(ShowServer, false);
|
||||
SetUI(ShowHost, false);
|
||||
SetUI(ShowClient, false);
|
||||
SetUI(ShowDisconnected, true);
|
||||
break;
|
||||
case Status.Server:
|
||||
SetUI(ShowDisconnected, false);
|
||||
SetUI(ShowHost, false);
|
||||
SetUI(ShowClient, false);
|
||||
SetUI(ShowServer, true);
|
||||
break;
|
||||
case Status.Host:
|
||||
SetUI(ShowDisconnected, false);
|
||||
SetUI(ShowServer, false);
|
||||
SetUI(ShowClient, false);
|
||||
SetUI(ShowHost, true);
|
||||
break;
|
||||
case Status.Client:
|
||||
SetUI(ShowDisconnected, false);
|
||||
SetUI(ShowServer, false);
|
||||
SetUI(ShowHost, false);
|
||||
SetUI(ShowClient, true);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUI(GameObject[] gos, bool active)
|
||||
{
|
||||
foreach (GameObject go in gos)
|
||||
{
|
||||
go.SetActive(active);
|
||||
}
|
||||
}
|
||||
private Status GetStatus()
|
||||
{
|
||||
if (NetworkServer.active && NetworkClient.active)
|
||||
{
|
||||
return Status.Host;
|
||||
}
|
||||
if (NetworkServer.active)
|
||||
{
|
||||
return Status.Server;
|
||||
}
|
||||
if (NetworkClient.active)
|
||||
{
|
||||
return Status.Client;
|
||||
}
|
||||
return Status.Offline;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d2f1170bbe4432bf6f388bcfabefee
|
||||
timeCreated: 1710138272
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/Scripts/UILobbyStatus.cs
|
||||
uploadId: 736421
|
11
Assets/Mirror/Examples/EdgegapLobby/_ReadMe.txt
Normal file
11
Assets/Mirror/Examples/EdgegapLobby/_ReadMe.txt
Normal file
@ -0,0 +1,11 @@
|
||||
Docs: https://mirror-networking.gitbook.io/docs/manual/examples/edgegap-lobby
|
||||
This is a copy of the Tanks example (basic scene with player controlled tanks),
|
||||
but with a lobby ui for using Edgegap's Lobby and Relay service.
|
||||
It showcases how one might interact with the EdgegapLobbyKcpTransport to list, join and create lobbies.
|
||||
Providing a good starting point for anyone wanting to use Edgegap lobbies.
|
||||
|
||||
# Setup
|
||||
As this example uses external services from Edgegap you will need to set up the transport
|
||||
on the NetworkManager gameobject before you can use it.
|
||||
Please see the EdgegapLobbyKcpTransport Setup instructions on how to do that:
|
||||
https://mirror-networking.gitbook.io/docs/manual/transports/edgegap-relay-transport#setup
|
14
Assets/Mirror/Examples/EdgegapLobby/_ReadMe.txt.meta
Normal file
14
Assets/Mirror/Examples/EdgegapLobby/_ReadMe.txt.meta
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6c3a72e7e659a7459a3ba3adb15b2e0
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 129321
|
||||
packageName: Mirror
|
||||
packageVersion: 96.0.1
|
||||
assetPath: Assets/Mirror/Examples/EdgegapLobby/_ReadMe.txt
|
||||
uploadId: 736421
|
Reference in New Issue
Block a user