Update
This commit is contained in:
1
Assets/.gemini-workspace-history/active-context.md
Normal file
1
Assets/.gemini-workspace-history/active-context.md
Normal file
@@ -0,0 +1 @@
|
||||
No previous session history found for this workspace.
|
||||
15
Assets/.idea/.gitignore
generated
vendored
Normal file
15
Assets/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/contentModel.xml
|
||||
/.idea.Assets.iml
|
||||
/modules.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
4
Assets/.idea/encodings.xml
generated
Normal file
4
Assets/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
Assets/.idea/indexLayout.xml
generated
Normal file
8
Assets/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
Assets/.idea/vcs.xml
generated
Normal file
6
Assets/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
File diff suppressed because one or more lines are too long
@@ -185,11 +185,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::_PlayerDataManager
|
||||
_Players:
|
||||
_items: []
|
||||
--- !u!137 &166789747 stripped
|
||||
SkinnedMeshRenderer:
|
||||
m_CorrespondingSourceObject: {fileID: 1058696422167757239, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_PrefabInstance: {fileID: 8240317044381527393}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &200732282
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -317,22 +312,6 @@ MonoBehaviour:
|
||||
m_ShadowLayerMask: 1
|
||||
m_RenderingLayers: 1
|
||||
m_ShadowRenderingLayers: 1
|
||||
--- !u!4 &216247148 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_PrefabInstance: {fileID: 8240317044381527393}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &216247156 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 5600577104145922999, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_PrefabInstance: {fileID: 8240317044381527393}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5962d8f2c8e40e240a4a4907c7b539fa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.InputReader
|
||||
--- !u!1 &390662298
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -364,11 +343,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1439162687}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!20 &442028704 stripped
|
||||
Camera:
|
||||
m_CorrespondingSourceObject: {fileID: 452500236988029996, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
m_PrefabInstance: {fileID: 3886963620680427248}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &442028708 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
@@ -627,9 +601,9 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1437922948}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 3.5546, y: -66, z: 4.39807}
|
||||
m_LocalScale: {x: 50, y: 1, z: 50}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 100, y: 1, z: 100}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1313417867}
|
||||
@@ -700,16 +674,6 @@ MonoBehaviour:
|
||||
visualizationInterval: 0.05
|
||||
mazeRenderer: {fileID: 1439162688}
|
||||
mazeContainer: {fileID: 390662299}
|
||||
--- !u!4 &1631120432 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 5188652905305800431, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_PrefabInstance: {fileID: 8240317044381527393}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &1732205146 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 8004958684693924044, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_PrefabInstance: {fileID: 8240317044381527393}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1997343488
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -740,42 +704,10 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 442028708}
|
||||
- {fileID: 216247148}
|
||||
- {fileID: 1313417867}
|
||||
- {fileID: 1368410213}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2101138892
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2101138893}
|
||||
m_Layer: 0
|
||||
m_Name: Campoint 1
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2101138893
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2101138892}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: 0.9727903, z: -0, w: 0.23168753}
|
||||
m_LocalPosition: {x: -1.8390989, y: -1.7589655, z: 7.503214}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1732205146}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &3886963620680427248
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -835,11 +767,11 @@ PrefabInstance:
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: fpvTarget
|
||||
value:
|
||||
objectReference: {fileID: 1631120432}
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: inputReader
|
||||
value:
|
||||
objectReference: {fileID: 216247156}
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: sensitivity
|
||||
value: 10
|
||||
@@ -847,15 +779,15 @@ PrefabInstance:
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: followTarget
|
||||
value:
|
||||
objectReference: {fileID: 216247148}
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: 'characterRenderers.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 166789747}
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: 'characterFading.characterRenderers.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 166789747}
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8391577239842762580, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: m_RenderPostProcessing
|
||||
value: 1
|
||||
@@ -865,153 +797,6 @@ PrefabInstance:
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
--- !u!1001 &8240317044381527393
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 1997343489}
|
||||
m_Modifications:
|
||||
- target: {fileID: -5076913349690967641, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: SortKey
|
||||
value: 225553585
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 830356296960548640, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: <InteractionMask>k__BackingField.m_Bits
|
||||
value: 512
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1054594849095937263, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Player
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1054594849095937263, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_TagString
|
||||
value: Player
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1058696422167757239, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: 'm_Materials.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 3297912226980038121, guid: 8290c8e8479e3b744b22042adbe32801, type: 3}
|
||||
- target: {fileID: 1058696422167757239, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: 'm_Materials.Array.data[1]'
|
||||
value:
|
||||
objectReference: {fileID: 2100000, guid: 29d8aeef71b97864a9ad6317a4738f26, type: 2}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Camera
|
||||
value:
|
||||
objectReference: {fileID: 442028704}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.size
|
||||
value: 21
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_ActionId
|
||||
value: 7e8b9416-0a2d-4652-98d8-e7368560ede9
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_ActionName
|
||||
value: 'Player/Change View[/Keyboard/f2]'
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.size
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 216247156}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: OnToggleView
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
value: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -3.51
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -5.22
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -9.01
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3866929919288054183, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: redSlashPrefab
|
||||
value:
|
||||
objectReference: {fileID: 1113287330716207023, guid: 03163717f6c5cad409e7e7f079f06ea5, type: 3}
|
||||
- target: {fileID: 3866929919288054183, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: blackSlashPrefab
|
||||
value:
|
||||
objectReference: {fileID: 7925862234553078923, guid: a9db8dc0d7288b8418ab54e786fbffa7, type: 3}
|
||||
- target: {fileID: 5073031060995569267, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: autoDetectOnStart
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: cinematicCameraPoint
|
||||
value:
|
||||
objectReference: {fileID: 2101138893}
|
||||
- target: {fileID: 9098752589608501196, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Controller
|
||||
value:
|
||||
objectReference: {fileID: 9100000, guid: 09e31034ca0f14f42b3aa81e50326f87, type: 2}
|
||||
m_RemovedComponents:
|
||||
- {fileID: 6587788942094262397, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
- {fileID: 5294322338071205561, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
- {fileID: 8541105841172983867, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects:
|
||||
- targetCorrespondingSourceObject: {fileID: 8004958684693924044, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 2101138893}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -72,8 +72,13 @@ namespace Hallucinate.UI
|
||||
await _runner.Shutdown();
|
||||
}
|
||||
|
||||
Debug.Log("[BasicSpawner] Destroying existing runner component.");
|
||||
Destroy(_runner);
|
||||
// Check if it still exists (Unity pseudo-null check)
|
||||
if (_runner != null)
|
||||
{
|
||||
// Only log if it's actually a valid object to destroy
|
||||
// If it's already marked for destruction, Unity == null will be true soon
|
||||
Destroy(_runner);
|
||||
}
|
||||
_runner = null;
|
||||
|
||||
await Task.Yield();
|
||||
@@ -84,6 +89,8 @@ namespace Hallucinate.UI
|
||||
}
|
||||
}
|
||||
|
||||
if (this == null) return; // BasicSpawner itself might be destroyed
|
||||
|
||||
Debug.Log("[BasicSpawner] Creating new NetworkRunner component.");
|
||||
_runner = gameObject.AddComponent<NetworkRunner>();
|
||||
_runner.ProvideInput = true;
|
||||
@@ -118,7 +125,12 @@ namespace Hallucinate.UI
|
||||
|
||||
public async Task<bool> StartHost(string sessionName, string displayName, string password = null)
|
||||
{
|
||||
if (_isStarting) return false;
|
||||
// Wait for any existing startup process (like StartLobby) to finish
|
||||
while (_isStarting)
|
||||
{
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
_isStarting = true;
|
||||
|
||||
try
|
||||
|
||||
@@ -24,15 +24,22 @@ public class PlayerDataManager : NetworkBehaviour
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public override void Despawned(NetworkRunner runner, bool hasState)
|
||||
{
|
||||
if (Instance == this) Instance = null;
|
||||
}
|
||||
|
||||
[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
|
||||
public void RPC_UpdatePlayerMetaData(PlayerRef playerRef, _PlayerMetaData metaData)
|
||||
{
|
||||
if (Object == null || !Object.IsValid) return;
|
||||
Players.Set(playerRef, metaData);
|
||||
}
|
||||
|
||||
[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
|
||||
public void RPC_SetReady(PlayerRef playerRef, bool ready)
|
||||
{
|
||||
if (Object == null || !Object.IsValid) return;
|
||||
if (Players.TryGet(playerRef, out var data))
|
||||
{
|
||||
data.IsReady = ready;
|
||||
@@ -48,6 +55,10 @@ public class PlayerDataManager : NetworkBehaviour
|
||||
|
||||
public bool TryGetPlayerMetaData(PlayerRef playerRef, out _PlayerMetaData metaData)
|
||||
{
|
||||
metaData = default;
|
||||
// Kiểm tra xem object đã được Spawned chưa trước khi truy cập networked property
|
||||
if (Object == null || !Object.IsValid) return false;
|
||||
|
||||
return Players.TryGet(playerRef, out metaData);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
@@ -31,6 +31,8 @@ namespace Hallucinate.UI
|
||||
private Label _guestChatMessage;
|
||||
private TextField _chatInput;
|
||||
|
||||
private bool _isBusy = false;
|
||||
|
||||
public override void Initialize(VisualElement uxmlRoot, UIManager manager)
|
||||
{
|
||||
base.Initialize(uxmlRoot, manager);
|
||||
@@ -49,6 +51,7 @@ namespace Hallucinate.UI
|
||||
_loungeRoomName = root.Q<Label>("LoungeRoomName");
|
||||
_readyBtn = root.Q<Button>("ReadyBtn");
|
||||
_startBtn = root.Q<Button>("StartBtn");
|
||||
if (_startBtn != null) _startBtn.style.display = DisplayStyle.None; // Default to hidden
|
||||
_hostNameLabel = root.Q<Label>("HostName");
|
||||
_hostStatusLabel = root.Q<Label>("HostReadyStatus");
|
||||
_hostChatBox = root.Q<VisualElement>("HostChatBox");
|
||||
@@ -59,9 +62,10 @@ namespace Hallucinate.UI
|
||||
_guestChatMessage = root.Q<Label>("GuestChatMessage");
|
||||
_chatInput = root.Q<TextField>("ChatInput");
|
||||
|
||||
|
||||
root.Q<Button>("GoToCreateBtn").clicked += ShowCreate;
|
||||
root.Q<Button>("CancelCreateBtn").clicked += ShowJoin;
|
||||
root.Q<Button>("BackToMenuBtn").clicked += async () => await uiManager.Pop();
|
||||
root.Q<Button>("BackToMenuBtn").clicked += async () => { if (_isBusy) return; await uiManager.Pop(); };
|
||||
_confirmCreateBtn = root.Q<Button>("ConfirmCreateBtn");
|
||||
if (_confirmCreateBtn != null) _confirmCreateBtn.clicked += OnCreateRoomClicked;
|
||||
root.Q<Button>("ConfirmJoinBtn").clicked += OnConfirmPasswordClicked;
|
||||
@@ -103,7 +107,8 @@ namespace Hallucinate.UI
|
||||
{
|
||||
var runner = Object.FindFirstObjectByType<NetworkRunner>();
|
||||
if (runner == null) return;
|
||||
bool isHost = sender.PlayerId == 1;
|
||||
var sortedPlayers = runner.ActivePlayers.OrderBy(p => p.PlayerId).ToList();
|
||||
bool isHost = sortedPlayers.Count > 0 && sender == sortedPlayers[0];
|
||||
if (isHost) ShowChatBubble(_hostChatBox, _hostChatMessage, message);
|
||||
else ShowChatBubble(_guestChatBox, _guestChatMessage, message);
|
||||
}
|
||||
@@ -120,7 +125,13 @@ namespace Hallucinate.UI
|
||||
private void ApplyLocalization() { if (LocalizationManager.Instance == null) return; }
|
||||
private string GetT(string key) => LocalizationManager.Instance != null ? LocalizationManager.Instance.GetLocalizedString(key) : key;
|
||||
public void SetRoomTemplate(VisualTreeAsset template) => _roomItemTemplate = template;
|
||||
public override async Task PlayTransitionIn() { await base.PlayTransitionIn(); ShowJoin(); }
|
||||
|
||||
public override async Task PlayTransitionIn()
|
||||
{
|
||||
_isBusy = false;
|
||||
await base.PlayTransitionIn();
|
||||
ShowJoin();
|
||||
}
|
||||
|
||||
public void ShowJoin()
|
||||
{
|
||||
@@ -158,18 +169,39 @@ namespace Hallucinate.UI
|
||||
|
||||
private async void OnCreateRoomClicked()
|
||||
{
|
||||
if (_isBusy) return;
|
||||
_isBusy = true;
|
||||
|
||||
if (_confirmCreateBtn != null) _confirmCreateBtn.SetEnabled(false);
|
||||
if (_createErrorLabel != null) _createErrorLabel.style.display = DisplayStyle.None;
|
||||
|
||||
var spawner = BasicSpawner.Instance;
|
||||
if (spawner == null) { ShowCreateError("System Error: Spawner missing. Please re-enter the Lobby."); return; }
|
||||
if (spawner == null)
|
||||
{
|
||||
ShowCreateError("System Error: Spawner missing. Please re-enter the Lobby.");
|
||||
_isBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
string id = (_roomIDInput != null && !string.IsNullOrEmpty(_roomIDInput.value)) ? _roomIDInput.value.Trim() : "ROOM_" + Random.Range(1000, 9999).ToString();
|
||||
string name = (_roomNameInput != null && !string.IsNullOrEmpty(_roomNameInput.value)) ? _roomNameInput.value.Trim() : id;
|
||||
string pass = (_passToggle != null && _passToggle.value && _roomPassInput != null) ? _roomPassInput.value : null;
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
bool success = await spawner.StartHost(id, name, pass);
|
||||
if (success) ShowLounge(name);
|
||||
else ShowCreateError("Failed to create room. ID might be taken.");
|
||||
} catch (System.Exception ex) { ShowCreateError("Network Error: " + ex.Message); }
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
ShowCreateError("Network Error: " + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isBusy = false;
|
||||
if (_confirmCreateBtn != null) _confirmCreateBtn.SetEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowCreateError(string message)
|
||||
@@ -203,6 +235,8 @@ namespace Hallucinate.UI
|
||||
|
||||
private async void OnRoomItemClicked(SessionInfo session)
|
||||
{
|
||||
if (_isBusy) return;
|
||||
|
||||
bool needsPass = session.Properties.ContainsKey("pw");
|
||||
if (needsPass)
|
||||
{
|
||||
@@ -216,16 +250,49 @@ namespace Hallucinate.UI
|
||||
|
||||
private async void OnConfirmPasswordClicked()
|
||||
{
|
||||
if (_selectedSession == null) return;
|
||||
if (_isBusy || _selectedSession == null) return;
|
||||
_isBusy = true;
|
||||
|
||||
string pass = _joinPassInput != null ? _joinPassInput.value : "";
|
||||
if (_passOverlay != null) _passOverlay.style.display = DisplayStyle.None;
|
||||
await JoinRoom(_selectedSession.Name, pass);
|
||||
_isBusy = false;
|
||||
}
|
||||
|
||||
private async Task JoinRoom(string sessionName, string password) { if (BasicSpawner.Instance != null) { if (await BasicSpawner.Instance.StartClient(sessionName, password)) ShowLounge(sessionName); } }
|
||||
private void OnReadyClicked() { var runner = Object.FindFirstObjectByType<NetworkRunner>(); if (runner != null && _playerDataManager != null && _playerDataManager.TryGetPlayerMetaData(runner.LocalPlayer, out var myData)) _playerDataManager.RPC_SetReady(runner.LocalPlayer, !myData.IsReady); }
|
||||
private void OnStartClicked() { BasicSpawner.Instance?.StartGame(); }
|
||||
private async void OnLeaveLoungeClicked() { var runner = Object.FindFirstObjectByType<NetworkRunner>(); if (runner != null) await runner.Shutdown(); if (_playerDataManager != null) _playerDataManager.OnChatMessageReceived -= OnChatMessageReceived; ShowJoin(); }
|
||||
private async Task JoinRoom(string sessionName, string password)
|
||||
{
|
||||
if (BasicSpawner.Instance != null)
|
||||
{
|
||||
if (await BasicSpawner.Instance.StartClient(sessionName, password)) ShowLounge(sessionName);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnReadyClicked()
|
||||
{
|
||||
if (_isBusy) return;
|
||||
var runner = Object.FindFirstObjectByType<NetworkRunner>();
|
||||
if (runner != null && _playerDataManager != null && _playerDataManager.TryGetPlayerMetaData(runner.LocalPlayer, out var myData))
|
||||
_playerDataManager.RPC_SetReady(runner.LocalPlayer, !myData.IsReady);
|
||||
}
|
||||
|
||||
private void OnStartClicked()
|
||||
{
|
||||
if (_isBusy) return;
|
||||
BasicSpawner.Instance?.StartGame();
|
||||
}
|
||||
|
||||
private async void OnLeaveLoungeClicked()
|
||||
{
|
||||
if (_isBusy) return;
|
||||
_isBusy = true;
|
||||
|
||||
var runner = Object.FindFirstObjectByType<NetworkRunner>();
|
||||
if (runner != null) await runner.Shutdown(false);
|
||||
if (_playerDataManager != null) _playerDataManager.OnChatMessageReceived -= OnChatMessageReceived;
|
||||
ShowJoin();
|
||||
|
||||
_isBusy = false;
|
||||
}
|
||||
|
||||
public override void Update() { if (_loungeContainer != null && _loungeContainer.style.display == DisplayStyle.Flex) UpdateLoungeUI(); }
|
||||
|
||||
@@ -234,24 +301,44 @@ namespace Hallucinate.UI
|
||||
var spawner = BasicSpawner.Instance;
|
||||
if (spawner == null) return;
|
||||
var runner = spawner.Runner;
|
||||
if (runner == null || _playerDataManager == null || _playerDataManager.Object == null || !_playerDataManager.Object.IsValid) return;
|
||||
if (runner == null) return;
|
||||
|
||||
PlayerRef hostRef = PlayerRef.None;
|
||||
PlayerRef guestRef = PlayerRef.None;
|
||||
// 1. Strict Visibility Check
|
||||
bool isHost = runner.IsServer;
|
||||
if (_startBtn != null)
|
||||
{
|
||||
_startBtn.style.display = isHost ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
}
|
||||
|
||||
// 2. PlayerDataManager Sync
|
||||
if (_playerDataManager == null || _playerDataManager.Object == null || !_playerDataManager.Object.IsValid)
|
||||
{
|
||||
_playerDataManager = PlayerDataManager.Instance;
|
||||
if (_playerDataManager != null)
|
||||
{
|
||||
_playerDataManager.OnChatMessageReceived += OnChatMessageReceived;
|
||||
}
|
||||
else return; // Still waiting for synchronization
|
||||
}
|
||||
|
||||
// 3. Identify Players
|
||||
var sortedPlayers = runner.ActivePlayers.OrderBy(p => p.PlayerId).ToList();
|
||||
if (sortedPlayers.Count > 0) hostRef = sortedPlayers[0];
|
||||
if (sortedPlayers.Count > 1) guestRef = sortedPlayers[1];
|
||||
PlayerRef hostRef = sortedPlayers.Count > 0 ? sortedPlayers[0] : PlayerRef.None;
|
||||
PlayerRef guestRef = sortedPlayers.Count > 1 ? sortedPlayers[1] : PlayerRef.None;
|
||||
|
||||
if (runner.SessionInfo != null && runner.SessionInfo.Properties.TryGetValue("rn", out var rnProp)) _loungeRoomName.text = rnProp.ToString().ToUpper();
|
||||
|
||||
// Host Display
|
||||
if (hostRef != PlayerRef.None && _playerDataManager.TryGetPlayerMetaData(hostRef, out var hostData))
|
||||
{
|
||||
_hostNameLabel.text = hostData.Name.ToString().ToUpper();
|
||||
_hostStatusLabel.text = hostData.IsReady ? GetT("LOBBY_READY") : GetT("LOBBY_NOT_READY");
|
||||
string readyStatus = hostData.IsReady ? GetT("LOBBY_READY") : GetT("LOBBY_NOT_READY");
|
||||
_hostStatusLabel.text = $"{GetT("LOBBY_HOST_LABEL")} - {readyStatus}";
|
||||
_hostStatusLabel.style.color = hostData.IsReady ? Color.green : Color.red;
|
||||
}
|
||||
else if (hostRef != PlayerRef.None) { _hostNameLabel.text = GetT("LOBBY_SYNCING"); _hostStatusLabel.text = "-"; }
|
||||
else { _hostNameLabel.text = GetT("LOBBY_SYNCING"); _hostStatusLabel.text = "-"; }
|
||||
|
||||
// Guest Display
|
||||
if (guestRef != PlayerRef.None && _playerDataManager.TryGetPlayerMetaData(guestRef, out var guestData))
|
||||
{
|
||||
_guestNameLabel.text = guestData.Name.ToString().ToUpper();
|
||||
@@ -261,17 +348,55 @@ namespace Hallucinate.UI
|
||||
else if (runner.ActivePlayers.Count() >= 2) { _guestNameLabel.text = GetT("LOBBY_SYNCING"); _guestStatusLabel.text = "-"; }
|
||||
else { _guestNameLabel.text = GetT("LOBBY_WAITING_LABEL"); _guestStatusLabel.text = "-"; _guestStatusLabel.style.color = Color.gray; }
|
||||
|
||||
bool allReady = true;
|
||||
int playerCount = 0;
|
||||
foreach (var p in runner.ActivePlayers) { playerCount++; if (_playerDataManager.TryGetPlayerMetaData(p, out var data)) { if (!data.IsReady) allReady = false; } else allReady = false; }
|
||||
|
||||
bool isHost = runner.LocalPlayer == hostRef;
|
||||
if (_startBtn != null) { _startBtn.text = GetT("LOBBY_START_BTN"); _startBtn.style.display = isHost ? DisplayStyle.Flex : DisplayStyle.None; _startBtn.SetEnabled(allReady && playerCount >= 2); }
|
||||
|
||||
if (_readyBtn != null && _playerDataManager.TryGetPlayerMetaData(runner.LocalPlayer, out var myData))
|
||||
// 4. Start Button Logic (Host Only)
|
||||
if (_startBtn != null && isHost)
|
||||
{
|
||||
if (myData.IsReady) { _readyBtn.text = GetT("LOBBY_UNREADY_BTN"); _readyBtn.style.backgroundColor = new StyleColor(Color.green); _readyBtn.style.color = new StyleColor(Color.black); }
|
||||
else { _readyBtn.text = GetT("LOBBY_READY_BTN"); _readyBtn.style.backgroundColor = new StyleColor(new Color(0.2f, 0.2f, 0.2f, 0.8f)); _readyBtn.style.color = new StyleColor(Color.white); }
|
||||
bool allReady = true;
|
||||
int playerCount = 0;
|
||||
foreach (var p in runner.ActivePlayers)
|
||||
{
|
||||
playerCount++;
|
||||
if (_playerDataManager.TryGetPlayerMetaData(p, out var data))
|
||||
{
|
||||
if (!data.IsReady) allReady = false;
|
||||
}
|
||||
else allReady = false;
|
||||
}
|
||||
|
||||
bool canStart = allReady && playerCount >= 2;
|
||||
_startBtn.SetEnabled(canStart);
|
||||
_startBtn.text = GetT("LOBBY_START_BTN");
|
||||
|
||||
if (canStart)
|
||||
{
|
||||
_startBtn.style.backgroundColor = new StyleColor(Color.green);
|
||||
_startBtn.style.color = new StyleColor(Color.black);
|
||||
}
|
||||
else
|
||||
{
|
||||
_startBtn.style.backgroundColor = new StyleColor(new Color(0.2f, 0.2f, 0.2f, 0.8f));
|
||||
_startBtn.style.color = new StyleColor(new Color(1f, 1f, 1f, 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
// Ready Button Logic (Everyone)
|
||||
if (_readyBtn != null)
|
||||
{
|
||||
if (_playerDataManager.TryGetPlayerMetaData(runner.LocalPlayer, out var myData))
|
||||
{
|
||||
if (myData.IsReady)
|
||||
{
|
||||
_readyBtn.text = GetT("LOBBY_UNREADY_BTN");
|
||||
_readyBtn.style.backgroundColor = new StyleColor(Color.green);
|
||||
_readyBtn.style.color = new StyleColor(Color.black);
|
||||
}
|
||||
else
|
||||
{
|
||||
_readyBtn.text = GetT("LOBBY_READY_BTN");
|
||||
_readyBtn.style.backgroundColor = new StyleColor(new Color(0.2f, 0.2f, 0.2f, 0.8f));
|
||||
_readyBtn.style.color = new StyleColor(Color.white);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Hallucinate.UI
|
||||
private Tween _rotationTween;
|
||||
private Texture2D _currentIcon;
|
||||
|
||||
private bool _isBusy = false;
|
||||
|
||||
public override void Initialize(VisualElement uxmlRoot, UIManager manager)
|
||||
{
|
||||
base.Initialize(uxmlRoot, manager);
|
||||
@@ -42,11 +44,11 @@ namespace Hallucinate.UI
|
||||
_logo.RegisterCallback<ClickEvent>(OnLogoClicked);
|
||||
|
||||
var settingsBtn = root.Q<Button>("SettingsBtn");
|
||||
if (settingsBtn != null) settingsBtn.clicked += () => uiManager.ToggleSettings();
|
||||
if (settingsBtn != null) settingsBtn.clicked += () => { if (_isBusy) return; uiManager.ToggleSettings(); };
|
||||
|
||||
root.Q<Button>("JoinBtn").clicked += async () => await uiManager.Push<LobbyController>();
|
||||
root.Q<Button>("CreateBtn").clicked += async () => await uiManager.Push<LobbyController>();
|
||||
root.Q<Button>("ProfileBtn").clicked += async () => await uiManager.Push<ProfileController>();
|
||||
root.Q<Button>("JoinBtn").clicked += async () => { if (_isBusy) return; _isBusy = true; await uiManager.Push<LobbyController>(); };
|
||||
root.Q<Button>("CreateBtn").clicked += async () => { if (_isBusy) return; _isBusy = true; await uiManager.Push<LobbyController>(); };
|
||||
root.Q<Button>("ProfileBtn").clicked += async () => { if (_isBusy) return; _isBusy = true; await uiManager.Push<ProfileController>(); };
|
||||
root.Q<Button>("ExitBtn").clicked += () => Application.Quit();
|
||||
|
||||
// Đăng ký Localization
|
||||
@@ -142,6 +144,7 @@ namespace Hallucinate.UI
|
||||
|
||||
public override async Task PlayTransitionIn()
|
||||
{
|
||||
_isBusy = false;
|
||||
_lastInteractionTime = Time.time;
|
||||
_currentState = MenuState.Idle;
|
||||
ResetLogoPosition();
|
||||
@@ -167,9 +170,14 @@ namespace Hallucinate.UI
|
||||
|
||||
private async void OnLogoClicked(ClickEvent evt)
|
||||
{
|
||||
if (_isBusy) return;
|
||||
_lastInteractionTime = Time.time;
|
||||
if (_currentState == MenuState.Idle) TransitionToRibbon();
|
||||
else await uiManager.Push<LobbyController>();
|
||||
else
|
||||
{
|
||||
_isBusy = true;
|
||||
await uiManager.Push<LobbyController>();
|
||||
}
|
||||
}
|
||||
|
||||
private void TransitionToRibbon()
|
||||
|
||||
76
Assets/Scripts/UI/PauseMenuController.cs
Normal file
76
Assets/Scripts/UI/PauseMenuController.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using UnityEngine.UIElements;
|
||||
using System.Threading.Tasks;
|
||||
using OnlyScove.Scripts;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Hallucinate.UI
|
||||
{
|
||||
public class PauseMenuController : BaseUIController
|
||||
{
|
||||
private Button _resumeBtn;
|
||||
private Button _quitBtn;
|
||||
|
||||
public override void Initialize(VisualElement uxmlRoot, UIManager manager)
|
||||
{
|
||||
base.Initialize(uxmlRoot, manager);
|
||||
|
||||
_resumeBtn = root.Q<Button>("ResumeBtn");
|
||||
_quitBtn = root.Q<Button>("QuitBtn");
|
||||
|
||||
if (_resumeBtn != null) _resumeBtn.clicked += OnResumeClicked;
|
||||
if (_quitBtn != null) _quitBtn.clicked += OnQuitClicked;
|
||||
|
||||
ApplyLocalization();
|
||||
if (LocalizationManager.Instance != null)
|
||||
LocalizationManager.Instance.OnLanguageChanged += ApplyLocalization;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (LocalizationManager.Instance != null)
|
||||
LocalizationManager.Instance.OnLanguageChanged -= ApplyLocalization;
|
||||
}
|
||||
|
||||
private void ApplyLocalization()
|
||||
{
|
||||
if (_resumeBtn != null) _resumeBtn.text = GetLoc("PAUSE_RESUME");
|
||||
if (_quitBtn != null) _quitBtn.text = GetLoc("PAUSE_QUIT");
|
||||
|
||||
var title = root.Q<Label>("PauseTitle");
|
||||
if (title != null) title.text = GetLoc("PAUSE_TITLE");
|
||||
}
|
||||
|
||||
private void OnResumeClicked()
|
||||
{
|
||||
uiManager.TogglePauseMenu();
|
||||
}
|
||||
|
||||
private void OnQuitClicked()
|
||||
{
|
||||
Debug.Log("[PauseMenu] Quit clicked - shutting down runner.");
|
||||
if (BasicSpawner.Instance != null && BasicSpawner.Instance.Runner != null)
|
||||
{
|
||||
BasicSpawner.Instance.Runner.Shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
uiManager.OnBackToMenu();
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task PlayTransitionIn()
|
||||
{
|
||||
Show();
|
||||
root.style.opacity = 0;
|
||||
PrimeTween.Tween.Custom(0f, 1f, duration: 0.2f, onValueChange: val => root.style.opacity = val);
|
||||
await Task.Delay(200);
|
||||
}
|
||||
|
||||
public override async Task PlayTransitionOut()
|
||||
{
|
||||
PrimeTween.Tween.Custom(1f, 0f, duration: 0.2f, onValueChange: val => root.style.opacity = val);
|
||||
await Task.Delay(200);
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/PauseMenuController.cs.meta
Normal file
2
Assets/Scripts/UI/PauseMenuController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8be766526476e44ea7c5e19567f2568
|
||||
@@ -39,6 +39,9 @@ namespace Hallucinate.UI
|
||||
private Action<float> _hoveredOnChanged;
|
||||
private float _sliderMin, _sliderMax;
|
||||
|
||||
// Audio Slider Tracking for Sync
|
||||
private readonly Dictionary<string, (Slider slider, TextField input)> _audioSliders = new Dictionary<string, (Slider slider, TextField input)>();
|
||||
|
||||
// Osu-style Volume Overlay
|
||||
private VisualElement _volumeContainer;
|
||||
private VisualElement _masterRing;
|
||||
@@ -303,6 +306,7 @@ namespace Hallucinate.UI
|
||||
_sectionHeaders["SOUND"] = header;
|
||||
_content.Add(header);
|
||||
|
||||
_audioSliders.Clear();
|
||||
_content.Add(CreateSubSection("AUDIO_VOLUMES"));
|
||||
_content.Add(CreateAudioSlider(GetT("MASTER"), "MasterVolume"));
|
||||
_content.Add(CreateAudioSlider(GetT("MUSIC"), "MusicVolume"));
|
||||
@@ -456,20 +460,31 @@ namespace Hallucinate.UI
|
||||
evt.StopPropagation();
|
||||
}
|
||||
|
||||
private void UpdateMasterVolume(float delta)
|
||||
{
|
||||
_masterVol = Mathf.Clamp(_masterVol + delta, 0f, 100f);
|
||||
PlayerPrefs.SetFloat("MasterVolume", _masterVol);
|
||||
AudioManager.Instance?.SetVolume("MasterVolume", _masterVol);
|
||||
_masterVolLabel.text = $"{Mathf.RoundToInt(_masterVol)}%";
|
||||
}
|
||||
private void UpdateMasterVolume(float delta) => UpdateVolume("MasterVolume", _masterVol + delta);
|
||||
|
||||
private void UpdateSubVolume(string key, float delta)
|
||||
private void UpdateSubVolume(string key, float delta) => UpdateVolume(key, PlayerPrefs.GetFloat(key, 80f) + delta);
|
||||
|
||||
private void UpdateVolume(string key, float volume, bool updateSlider = true)
|
||||
{
|
||||
float newVal = Mathf.Clamp(PlayerPrefs.GetFloat(key, 80f) + delta, 0f, 100f);
|
||||
PlayerPrefs.SetFloat(key, newVal);
|
||||
AudioManager.Instance?.SetVolume(key, newVal);
|
||||
if (_subRings.TryGetValue(key, out var data)) data.label.text = $"{Mathf.RoundToInt(newVal)}%";
|
||||
volume = Mathf.Clamp(volume, 0f, 100f);
|
||||
PlayerPrefs.SetFloat(key, volume);
|
||||
AudioManager.Instance?.SetVolume(key, volume);
|
||||
|
||||
if (key == "MasterVolume")
|
||||
{
|
||||
_masterVol = volume;
|
||||
if (_masterVolLabel != null) _masterVolLabel.text = $"{Mathf.RoundToInt(volume)}%";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_subRings.TryGetValue(key, out var data)) data.label.text = $"{Mathf.RoundToInt(volume)}%";
|
||||
}
|
||||
|
||||
if (updateSlider && _audioSliders.TryGetValue(key, out var sliderData))
|
||||
{
|
||||
sliderData.slider.SetValueWithoutNotify(volume);
|
||||
sliderData.input.value = volume.ToString("F1");
|
||||
}
|
||||
}
|
||||
|
||||
private async void ShowVolumeOverlay()
|
||||
@@ -508,12 +523,15 @@ namespace Hallucinate.UI
|
||||
return label;
|
||||
}
|
||||
|
||||
private VisualElement CreateSliderWithInput(string labelText, float min, float max, float startVal, Action<float> OnValueChanged)
|
||||
private VisualElement CreateSliderWithInput(string labelText, float min, float max, float startVal, Action<float> OnValueChanged, string audioKey = null)
|
||||
{
|
||||
var row = new VisualElement { style = { flexDirection = FlexDirection.Row, alignItems = Align.Center, marginTop = 5, marginBottom = 5 } };
|
||||
var label = new Label(labelText) { style = { width = Length.Percent(35) } }; label.AddToClassList("text-body");
|
||||
var slider = new Slider(min, max) { value = startVal, style = { flexGrow = 1 } };
|
||||
var input = new TextField { value = startVal.ToString("F1"), style = { width = 50, marginLeft = 10 } }; input.AddToClassList("input-field");
|
||||
|
||||
if (audioKey != null) _audioSliders[audioKey] = (slider, input);
|
||||
|
||||
slider.RegisterCallback<PointerEnterEvent>(evt => { _hoveredSlider = slider; _hoveredOnChanged = OnValueChanged; _sliderMin = min; _sliderMax = max; });
|
||||
slider.RegisterCallback<PointerLeaveEvent>(evt => { if (_hoveredSlider == slider) { _hoveredSlider = null; _hoveredOnChanged = null; } });
|
||||
slider.RegisterValueChangedCallback(evt => { float val = Mathf.Round(evt.newValue * 10f) / 10f; if (input.panel?.focusController?.focusedElement != input.ElementAt(0)) input.value = val.ToString("F1"); OnValueChanged?.Invoke(val); });
|
||||
@@ -524,12 +542,10 @@ namespace Hallucinate.UI
|
||||
private VisualElement CreateAudioSlider(string label, string prefKey)
|
||||
{
|
||||
var sliderRow = CreateSliderWithInput(label, 0, 100, PlayerPrefs.GetFloat(prefKey, 80), val => {
|
||||
PlayerPrefs.SetFloat(prefKey, val); AudioManager.Instance?.SetVolume(prefKey, val);
|
||||
});
|
||||
UpdateVolume(prefKey, val, false);
|
||||
}, prefKey);
|
||||
sliderRow.RegisterCallback<WheelEvent>(evt => {
|
||||
float newVal = Mathf.Clamp(PlayerPrefs.GetFloat(prefKey, 80f) - (evt.delta.y * 2f), 0f, 100f);
|
||||
PlayerPrefs.SetFloat(prefKey, newVal); AudioManager.Instance?.SetVolume(prefKey, newVal);
|
||||
var slider = sliderRow.Q<Slider>(); if (slider != null) slider.value = newVal;
|
||||
UpdateVolume(prefKey, PlayerPrefs.GetFloat(prefKey, 80f) - (evt.delta.y * 2f));
|
||||
});
|
||||
return sliderRow;
|
||||
}
|
||||
|
||||
@@ -49,12 +49,14 @@ namespace Hallucinate.UI
|
||||
[SerializeField] private VisualTreeAsset profileTemplate;
|
||||
[SerializeField] private VisualTreeAsset settingsTemplate;
|
||||
[SerializeField] private VisualTreeAsset hudTemplate;
|
||||
[SerializeField] private VisualTreeAsset pauseMenuTemplate;
|
||||
[SerializeField] private StyleSheet globalStyleSheet;
|
||||
|
||||
private LoginController _loginController;
|
||||
private MainMenuController _mainMenuController;
|
||||
private LobbyController _lobbyController;
|
||||
private SettingsController _settingsController;
|
||||
private PauseMenuController _pauseMenuController;
|
||||
|
||||
// Osu Trail Pooling
|
||||
private const int MAX_TRAIL_PARTICLES = 60;
|
||||
@@ -65,6 +67,9 @@ namespace Hallucinate.UI
|
||||
private bool _isSettingsOpen = false;
|
||||
public bool IsSettingsOpen => _isSettingsOpen;
|
||||
|
||||
private bool _isPauseMenuOpen = false;
|
||||
public bool IsPauseMenuOpen => _isPauseMenuOpen;
|
||||
|
||||
private const string UI_SCALE_KEY = "UIScale";
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -242,7 +247,43 @@ namespace Hallucinate.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCancel() { if (_isSettingsOpen) ToggleSettings(); }
|
||||
private void HandleCancel()
|
||||
{
|
||||
if (_isSettingsOpen) ToggleSettings();
|
||||
else if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Main Scene")
|
||||
{
|
||||
TogglePauseMenu();
|
||||
}
|
||||
}
|
||||
|
||||
public async void TogglePauseMenu()
|
||||
{
|
||||
if (_pauseMenuController == null) return;
|
||||
if (!_isPauseMenuOpen)
|
||||
{
|
||||
_isPauseMenuOpen = true;
|
||||
_pauseMenuController.Root.BringToFront();
|
||||
if (_cursorLayer != null) _cursorLayer.BringToFront();
|
||||
|
||||
// Unlock cursor when menu is open
|
||||
UnityEngine.Cursor.lockState = CursorLockMode.None;
|
||||
UnityEngine.Cursor.visible = false;
|
||||
|
||||
await _pauseMenuController.PlayTransitionIn();
|
||||
}
|
||||
else
|
||||
{
|
||||
_isPauseMenuOpen = false;
|
||||
|
||||
// Re-lock cursor when menu is closed
|
||||
if (!_isSettingsOpen)
|
||||
{
|
||||
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
|
||||
await _pauseMenuController.PlayTransitionOut();
|
||||
}
|
||||
}
|
||||
|
||||
public async void ToggleSettings()
|
||||
{
|
||||
@@ -354,6 +395,7 @@ namespace Hallucinate.UI
|
||||
RegisterController<ProfileController>(profileTemplate);
|
||||
_settingsController = RegisterController<SettingsController>(settingsTemplate);
|
||||
RegisterController<HUDController>(hudTemplate);
|
||||
_pauseMenuController = RegisterController<PauseMenuController>(pauseMenuTemplate);
|
||||
_loginController = RegisterController<LoginController>(loginTemplate);
|
||||
}
|
||||
catch (Exception e) { Debug.LogError($"[UIManager] Failed to initialize controllers: {e}"); }
|
||||
|
||||
File diff suppressed because one or more lines are too long
9
Assets/UI/PauseMenu.uxml
Normal file
9
Assets/UI/PauseMenu.uxml
Normal file
@@ -0,0 +1,9 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:VisualElement name="PauseMenuRoot" style="flex-grow: 1; align-items: center; justify-content: center; background-color: rgba(0, 0, 0, 0.7);">
|
||||
<ui:VisualElement name="PauseContainer" style="width: 400px; padding: 40px; background-color: rgba(20, 20, 20, 0.95); border-radius: 10px; border-width: 2px; border-color: rgb(0, 255, 204);">
|
||||
<ui:Label text="PAUSE" name="PauseTitle" style="font-size: 40px; color: rgb(0, 255, 204); -unity-font-style: bold; -unity-text-align: middle-center; margin-bottom: 30px;" />
|
||||
<ui:Button text="RESUME" name="ResumeBtn" class="button-spring" style="margin-bottom: 15px; height: 50px; font-size: 20px; color: white; background-color: rgba(255, 255, 255, 0.1); border-radius: 5px;" />
|
||||
<ui:Button text="LEAVE ROOM" name="QuitBtn" class="button-spring" style="height: 50px; font-size: 20px; color: rgb(255, 100, 100); background-color: rgba(255, 255, 255, 0.1); border-radius: 5px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
10
Assets/UI/PauseMenu.uxml.meta
Normal file
10
Assets/UI/PauseMenu.uxml.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65008e71286aba241b9118de2b48c457
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
Reference in New Issue
Block a user