Update
This commit is contained in:
9
.idea/.idea.HALLUCINATE/.idea/workspace.xml
generated
9
.idea/.idea.HALLUCINATE/.idea/workspace.xml
generated
@@ -6,7 +6,14 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="f9183c68-daf0-43b8-be4c-fad79983f91b" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/InputSystem_Actions.inputactions" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/InputSystem_Actions.inputactions" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scove/UIScaleTest.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scove/UIScaleTest.unity" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Player Controller/InputReader.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Player Controller/InputReader.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/SettingsController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/SettingsController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/UIManager.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/UIManager.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Assets/UI/Settings.uxml" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/Settings.uxml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ProjectSettings/ProjectSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/ProjectSettings.asset" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -143,7 +150,7 @@
|
||||
<workItem from="1777150520438" duration="58000" />
|
||||
<workItem from="1777150592854" duration="4699000" />
|
||||
<workItem from="1777181837663" duration="1519000" />
|
||||
<workItem from="1777269364664" duration="29967000" />
|
||||
<workItem from="1777269364664" duration="32024000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -642,6 +642,15 @@
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "ToggleSetting",
|
||||
"type": "Button",
|
||||
"id": "ae29d662-c797-4411-8ff3-8b5ad78427d8",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -1062,6 +1071,39 @@
|
||||
"action": "TrackedDeviceOrientation",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "One Modifier",
|
||||
"id": "112443de-ae57-4a55-a65c-98090d95ee75",
|
||||
"path": "OneModifier",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "ToggleSetting",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "modifier",
|
||||
"id": "4fae2510-0264-46ca-9c9d-9d2cb0ad32d1",
|
||||
"path": "<Keyboard>/leftCtrl",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "ToggleSetting",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "binding",
|
||||
"id": "822afb75-3d28-4c6d-8a32-3c7c65f81ddb",
|
||||
"path": "<Keyboard>/o",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "ToggleSetting",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -149,10 +149,13 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: bcb7b8ed439bb4546b0648c627c2ce5d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Hallucinate.UI.UIManager
|
||||
inputReader: {fileID: 2128442884}
|
||||
gameIcon: {fileID: 0}
|
||||
cursorSprite: {fileID: 21300000, guid: bf03bd4e32f382f45bd848d91517f188, type: 3}
|
||||
cursorTrailSprite: {fileID: 21300000, guid: b9c4a623634019648b505c6122243b00, type: 3}
|
||||
cursorSize: 30
|
||||
cursorSize: 57
|
||||
trailLength: 15
|
||||
trailSpacing: 2
|
||||
enableRipples: 1
|
||||
rippleColor: {r: 1, g: 1, b: 1, a: 0.5}
|
||||
mainMenuTemplate: {fileID: 9197481963319205126, guid: 8dcbe9fd5e8c43c43921af21a6347624, type: 3}
|
||||
@@ -462,10 +465,174 @@ MonoBehaviour:
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
m_Version: 2
|
||||
--- !u!1 &2128442883
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2128442885}
|
||||
- component: {fileID: 2128442884}
|
||||
- component: {fileID: 2128442886}
|
||||
m_Layer: 0
|
||||
m_Name: InputReader
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &2128442884
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2128442883}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5962d8f2c8e40e240a4a4907c7b539fa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.InputReader
|
||||
--- !u!4 &2128442885
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2128442883}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -16124.571, y: -11651.664, z: 100.93924}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2128442886
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2128442883}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.PlayerInput
|
||||
m_Actions: {fileID: -944628639613478452, guid: ac73bbdc8e64ac34c9525df400c1534f, type: 3}
|
||||
m_NotificationBehavior: 2
|
||||
m_UIInputModule: {fileID: 0}
|
||||
m_DeviceLostEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_DeviceRegainedEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ControlsChangedEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionEvents:
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 351f2ccd-1f9f-44bf-9bec-d62ac5c5f408
|
||||
m_ActionName: 'Player/Move[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 6b444451-8a00-4d00-a97e-f47457f736a8
|
||||
m_ActionName: 'Player/Look[/Mouse/delta]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 6c2ab1b8-8984-453a-af3d-a3c78ae1679a
|
||||
m_ActionName: 'Player/Attack[/Mouse/leftButton,/Keyboard/enter]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 852140f2-7766-474d-8707-702459ba45f3
|
||||
m_ActionName: 'Player/Interact[/Keyboard/e]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 27c5f898-bc57-4ee1-8800-db469aca5fe3
|
||||
m_ActionName: 'Player/Crouch[/Keyboard/c]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: f1ba0d36-48eb-4cd5-b651-1c94a6531f70
|
||||
m_ActionName: 'Player/Jump[/Keyboard/space]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 2776c80d-3c14-4091-8c56-d04ced07a2b0
|
||||
m_ActionName: 'Player/Previous[/Keyboard/q,/Keyboard/1]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: b7230bb6-fc9b-4f52-8b25-f5e19cb2c2ba
|
||||
m_ActionName: 'Player/Next[/Keyboard/e,/Keyboard/2]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 641cd816-40e6-41b4-8c3d-04687c349290
|
||||
m_ActionName: 'Player/Sprint[/Keyboard/leftShift]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 1702ffae-5ad3-4532-9855-bf7e2a8ae749
|
||||
m_ActionName: 'Player/Scroll[/Mouse/scroll]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 7e8b9416-0a2d-4652-98d8-e7368560ede9
|
||||
m_ActionName: 'Player/ToggleView[/Keyboard/f2]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: c95b2375-e6d9-4b88-9c4c-c5e76515df4b
|
||||
m_ActionName: 'UI/Navigate[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 7607c7b6-cd76-4816-beef-bd0341cfe950
|
||||
m_ActionName: 'UI/Submit[/Keyboard/enter]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 15cef263-9014-4fd5-94d9-4e4a6234a6ef
|
||||
m_ActionName: 'UI/Cancel[/Keyboard/escape]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 32b35790-4ed0-4e9a-aa41-69ac6d629449
|
||||
m_ActionName: 'UI/Point[/Mouse/position]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 3c7022bf-7922-4f7c-a998-c437916075ad
|
||||
m_ActionName: 'UI/Click[/Mouse/leftButton]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 44b200b1-1557-4083-816c-b22cbdf77ddf
|
||||
m_ActionName: 'UI/RightClick[/Mouse/rightButton]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: dad70c86-b58c-4b17-88ad-f5e53adf419e
|
||||
m_ActionName: 'UI/MiddleClick[/Mouse/middleButton]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 0489e84a-4833-4c40-bfae-cea84b696689
|
||||
m_ActionName: 'UI/ScrollWheel[/Mouse/scroll]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 24908448-c609-4bc3-a128-ea258674378a
|
||||
m_ActionName: UI/TrackedDevicePosition
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 9caa3d8a-6b2f-4e8e-8bad-6ede561bd9be
|
||||
m_ActionName: UI/TrackedDeviceOrientation
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: ae29d662-c797-4411-8ff3-8b5ad78427d8
|
||||
m_ActionName: 'UI/ToggleSetting[/Keyboard/leftCtrl,/Keyboard/o]'
|
||||
m_NeverAutoSwitchControlSchemes: 0
|
||||
m_DefaultControlScheme:
|
||||
m_DefaultActionMap: UI
|
||||
m_SplitScreenIndex: -1
|
||||
m_Camera: {fileID: 1848374380}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 1848374381}
|
||||
- {fileID: 626355270}
|
||||
- {fileID: 2128442885}
|
||||
- {fileID: 458228301}
|
||||
|
||||
@@ -10,10 +10,9 @@ namespace OnlyScove.Scripts
|
||||
public virtual Vector2 MoveInput { get; protected set; }
|
||||
public virtual Vector2 LookInput { get; protected set; }
|
||||
public virtual Vector2 ScrollInput { get; protected set; }
|
||||
public virtual bool IsSprintHeld { get; protected set; } // Left Shift
|
||||
public virtual bool IsAttackHeld { get; protected set; } // Left Mouse Button
|
||||
public virtual bool IsSprintHeld { get; protected set; }
|
||||
public virtual bool IsAttackHeld { get; protected set; }
|
||||
|
||||
// THÊM HÀM NÀY ĐỂ ĐỒNG BỘ MẠNG
|
||||
public void ApplyNetworkInput(Vector2 move, bool isSprint)
|
||||
{
|
||||
MoveInput = move;
|
||||
@@ -21,15 +20,19 @@ namespace OnlyScove.Scripts
|
||||
}
|
||||
|
||||
// One-shot Events
|
||||
public event Action OnJumpEvent; // Space
|
||||
public event Action OnDodgeEvent; // Right Mouse Button (RMB)
|
||||
public event Action OnSprintEvent; // Left Shift
|
||||
public event Action OnAttackEvent; // Left Mouse Button (LMB)
|
||||
public event Action OnCrouchEvent; // C Key
|
||||
public event Action OnInteractEvent; // E Key
|
||||
public event Action OnNextInteractEvent; // R Key
|
||||
public event Action OnPreviousInteractEvent; // Q Key
|
||||
public event Action OnToggleViewEvent; // F2 - New event for toggling camera view
|
||||
public event Action OnJumpEvent;
|
||||
public event Action OnDodgeEvent;
|
||||
public event Action OnSprintEvent;
|
||||
public event Action OnAttackEvent;
|
||||
public event Action OnCrouchEvent;
|
||||
public event Action OnInteractEvent;
|
||||
public event Action OnNextInteractEvent;
|
||||
public event Action OnPreviousInteractEvent;
|
||||
public event Action OnToggleViewEvent;
|
||||
|
||||
// UI Events
|
||||
public event Action OnToggleSettingsEvent; // Cho Ctrl+O
|
||||
public event Action OnCancelEvent; // Cho phím ESC hoặc phím đóng UI
|
||||
|
||||
public void OnAttack(InputAction.CallbackContext context)
|
||||
{
|
||||
@@ -69,13 +72,9 @@ namespace OnlyScove.Scripts
|
||||
if (context.canceled) IsSprintHeld = false;
|
||||
}
|
||||
|
||||
// New method for ToggleView input
|
||||
public void OnToggleView(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnToggleViewEvent?.Invoke();
|
||||
}
|
||||
if (context.performed) OnToggleViewEvent?.Invoke();
|
||||
}
|
||||
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
@@ -95,13 +94,7 @@ namespace OnlyScove.Scripts
|
||||
|
||||
public void OnInteract(InputAction.CallbackContext context)
|
||||
{
|
||||
Debug.Log($"[InputReader] Interaction State: {context.phase} | Started: {context.started} | Performed: {context.performed} | Canceled: {context.canceled}");
|
||||
|
||||
if (context.performed)
|
||||
{
|
||||
Debug.Log("[InputReader] Event OnInteractEvent triggered!");
|
||||
OnInteractEvent?.Invoke();
|
||||
}
|
||||
if (context.performed) OnInteractEvent?.Invoke();
|
||||
}
|
||||
|
||||
public void OnNext(InputAction.CallbackContext context)
|
||||
@@ -113,5 +106,20 @@ namespace OnlyScove.Scripts
|
||||
{
|
||||
if (context.performed) OnPreviousInteractEvent?.Invoke();
|
||||
}
|
||||
|
||||
// UI Callbacks
|
||||
public void OnToggleSettings(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
Debug.Log("[InputReader] Toggle Settings Action Performed!");
|
||||
OnToggleSettingsEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCancel(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed) OnCancelEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,6 @@ namespace Hallucinate.UI
|
||||
// Khởi động lại rotation nếu có icon
|
||||
StartRotation();
|
||||
|
||||
UnityEngine.Cursor.visible = true;
|
||||
await base.PlayTransitionIn();
|
||||
|
||||
// Nếu không phải lần đầu load (tức là quay lại bằng nút Back), tự động bung Ribbon
|
||||
|
||||
@@ -19,25 +19,38 @@ namespace Hallucinate.UI
|
||||
_tabTitle = root.Q<Label>("TabTitle");
|
||||
_content = root.Q<ScrollView>("SettingsContent");
|
||||
|
||||
// Logic đóng khi nhấn vào vùng nền bên ngoài sidebar
|
||||
root.RegisterCallback<ClickEvent>(evt => {
|
||||
if (evt.target == root)
|
||||
{
|
||||
uiManager.ToggleSettings();
|
||||
}
|
||||
});
|
||||
|
||||
root.Q<Button>("GeneralTab").clicked += () => SwitchTab("GENERAL");
|
||||
root.Q<Button>("VideoTab").clicked += () => SwitchTab("VIDEO");
|
||||
root.Q<Button>("SoundTab").clicked += () => SwitchTab("SOUND");
|
||||
root.Q<Button>("ControlTab").clicked += () => SwitchTab("CONTROL");
|
||||
root.Q<Button>("CloseSettingsBtn").clicked += () => uiManager.Pop();
|
||||
root.Q<Button>("CloseSettingsBtn").clicked += () => uiManager.ToggleSettings();
|
||||
}
|
||||
|
||||
private void SwitchTab(string title)
|
||||
{
|
||||
_tabTitle.text = title;
|
||||
// Clear and add specific settings content
|
||||
_content.Clear();
|
||||
_content.Add(new Label($"Settings for {title} coming soon..."));
|
||||
}
|
||||
|
||||
public override async Task PlayTransitionIn()
|
||||
{
|
||||
if (root != null) root.style.translate = new StyleTranslate(new Translate(0, 0));
|
||||
Show();
|
||||
// Reset vị trí root về 0 (Overlay trên màn hình hiện tại)
|
||||
if (root != null)
|
||||
{
|
||||
root.style.translate = new StyleTranslate(new Translate(0, 0));
|
||||
root.style.display = DisplayStyle.Flex;
|
||||
}
|
||||
|
||||
// Trượt sidebar từ trái vào
|
||||
_sidebar.style.translate = new StyleTranslate(new Translate(Length.Percent(-100), 0));
|
||||
await Tween.Custom(-100f, 0f, duration: 0.4f, ease: Ease.OutQuad,
|
||||
onValueChange: val => _sidebar.style.translate = new StyleTranslate(new Translate(Length.Percent(val), 0)));
|
||||
@@ -45,8 +58,10 @@ namespace Hallucinate.UI
|
||||
|
||||
public override async Task PlayTransitionOut()
|
||||
{
|
||||
// Trượt sidebar ra trái
|
||||
await Tween.Custom(0f, -100f, duration: 0.4f, ease: Ease.InQuad,
|
||||
onValueChange: val => _sidebar.style.translate = new StyleTranslate(new Translate(Length.Percent(val), 0)));
|
||||
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using PrimeTween;
|
||||
using OnlyScove.Scripts; // Namespace của InputReader
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
@@ -23,6 +24,9 @@ namespace Hallucinate.UI
|
||||
private readonly Dictionary<Type, BaseUIController> _controllers = new Dictionary<Type, BaseUIController>();
|
||||
private readonly Stack<BaseUIController> _history = new Stack<BaseUIController>();
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private InputReader inputReader;
|
||||
|
||||
[Header("Game Metadata")]
|
||||
[SerializeField] private Texture2D gameIcon;
|
||||
|
||||
@@ -43,14 +47,18 @@ namespace Hallucinate.UI
|
||||
[SerializeField] private VisualTreeAsset hudTemplate;
|
||||
|
||||
private MainMenuController _mainMenuController;
|
||||
private SettingsController _settingsController;
|
||||
private List<VisualElement> _trailSegments = new List<VisualElement>();
|
||||
private List<Vector2> _posHistory = new List<Vector2>();
|
||||
|
||||
private Vector2 _lastMousePos;
|
||||
private float _trailOpacity = 1f;
|
||||
private bool _isSettingsOpen = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
_uiDocument = GetComponent<UIDocument>();
|
||||
// Chỉ định rõ UnityEngine.Cursor để tránh lỗi Ambiguous
|
||||
UnityEngine.Cursor.visible = false;
|
||||
}
|
||||
|
||||
@@ -71,6 +79,13 @@ namespace Hallucinate.UI
|
||||
|
||||
_rootElement.RegisterCallback<PointerDownEvent>(OnGlobalClick, TrickleDown.TrickleDown);
|
||||
|
||||
// Đăng ký sự kiện từ InputReader (Chuẩn New Input System)
|
||||
if (inputReader != null)
|
||||
{
|
||||
inputReader.OnToggleSettingsEvent += ToggleSettings;
|
||||
inputReader.OnCancelEvent += HandleCancel;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (gameIcon == null)
|
||||
{
|
||||
@@ -81,6 +96,43 @@ namespace Hallucinate.UI
|
||||
InitializeControllers();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (inputReader != null)
|
||||
{
|
||||
inputReader.OnToggleSettingsEvent -= ToggleSettings;
|
||||
inputReader.OnCancelEvent -= HandleCancel;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCancel()
|
||||
{
|
||||
if (_isSettingsOpen) ToggleSettings();
|
||||
}
|
||||
|
||||
public async void ToggleSettings()
|
||||
{
|
||||
if (_settingsController == null) return;
|
||||
|
||||
if (!_isSettingsOpen)
|
||||
{
|
||||
_isSettingsOpen = true;
|
||||
_cursorLayer.BringToFront();
|
||||
await _settingsController.PlayTransitionIn();
|
||||
}
|
||||
else
|
||||
{
|
||||
_isSettingsOpen = false;
|
||||
await _settingsController.PlayTransitionOut();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_mainMenuController != null) _mainMenuController.Update();
|
||||
UpdateCursorAndTrail();
|
||||
}
|
||||
|
||||
private void SetupVirtualCursor()
|
||||
{
|
||||
_cursorLayer.Clear();
|
||||
@@ -98,7 +150,7 @@ namespace Hallucinate.UI
|
||||
segment.style.backgroundImage = new StyleBackground(Background.FromSprite(cursorTrailSprite));
|
||||
|
||||
float ratio = 1f - ((float)i / trailLength);
|
||||
segment.style.opacity = ratio * 0.5f;
|
||||
segment.style.opacity = 0f;
|
||||
segment.style.scale = new StyleScale(new Scale(new Vector3(ratio, ratio, 1f)));
|
||||
segment.style.translate = new StyleTranslate(new Translate(Length.Percent(-50), Length.Percent(-50)));
|
||||
segment.pickingMode = PickingMode.Ignore;
|
||||
@@ -118,6 +170,7 @@ namespace Hallucinate.UI
|
||||
_cursorLayer.Add(_mainCursor);
|
||||
|
||||
Vector2 startPos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
|
||||
_lastMousePos = startPos;
|
||||
for (int i = 0; i < trailLength * trailSpacing + 1; i++) _posHistory.Add(startPos);
|
||||
}
|
||||
|
||||
@@ -157,12 +210,6 @@ namespace Hallucinate.UI
|
||||
.OnComplete(() => ripple.RemoveFromHierarchy());
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_mainMenuController != null) _mainMenuController.Update();
|
||||
UpdateCursorAndTrail();
|
||||
}
|
||||
|
||||
private void UpdateCursorAndTrail()
|
||||
{
|
||||
if (!Application.isFocused)
|
||||
@@ -183,6 +230,12 @@ namespace Hallucinate.UI
|
||||
if (_cursorLayer != null) _cursorLayer.style.display = DisplayStyle.Flex;
|
||||
Vector2 uiPos = new Vector2(mousePos.x, Screen.height - mousePos.y);
|
||||
|
||||
float mouseSpeed = Vector2.Distance(uiPos, _lastMousePos);
|
||||
_lastMousePos = uiPos;
|
||||
|
||||
if (mouseSpeed > 0.1f) _trailOpacity = Mathf.MoveTowards(_trailOpacity, 1f, Time.deltaTime * 5f);
|
||||
else _trailOpacity = Mathf.MoveTowards(_trailOpacity, 0f, Time.deltaTime * 3f);
|
||||
|
||||
_posHistory.Insert(0, uiPos);
|
||||
if (_posHistory.Count > trailLength * trailSpacing + 1)
|
||||
_posHistory.RemoveAt(_posHistory.Count - 1);
|
||||
@@ -200,6 +253,8 @@ namespace Hallucinate.UI
|
||||
{
|
||||
_trailSegments[i].style.left = _posHistory[historyIndex].x;
|
||||
_trailSegments[i].style.top = _posHistory[historyIndex].y;
|
||||
float baseRatio = 1f - ((float)i / trailLength);
|
||||
_trailSegments[i].style.opacity = baseRatio * 0.5f * _trailOpacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,7 +266,7 @@ namespace Hallucinate.UI
|
||||
|
||||
RegisterController<LobbyController>(lobbyTemplate);
|
||||
RegisterController<ProfileController>(profileTemplate);
|
||||
RegisterController<SettingsController>(settingsTemplate);
|
||||
_settingsController = RegisterController<SettingsController>(settingsTemplate);
|
||||
RegisterController<HUDController>(hudTemplate);
|
||||
|
||||
_ = Push<MainMenuController>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<Style src="project:/Assets/UI/Global.uss" />
|
||||
<ui:VisualElement name="SettingsRoot" class="screen-root" style="background-color: rgba(0, 0, 0, 0.5); justify-content: flex-start;">
|
||||
<ui:VisualElement name="Sidebar" style="width: 400px; height: 100%; background-color: #1a1a1a; flex-direction: row;">
|
||||
<ui:VisualElement name="SettingsRoot" class="screen-root" picking-mode="Position" style="background-color: rgba(0, 0, 0, 0.5); justify-content: flex-start;">
|
||||
<ui:VisualElement name="Sidebar" picking-mode="Position" style="width: 400px; height: 100%; background-color: #1a1a1a; flex-direction: row;">
|
||||
<!-- Tabs -->
|
||||
<ui:VisualElement name="TabsColumn" style="width: 30%; background-color: #111; padding-top: 50px;">
|
||||
<ui:Button name="GeneralTab" text="General" class="button-spring" style="margin: 5px;" />
|
||||
@@ -15,7 +15,7 @@
|
||||
<ui:VisualElement name="DetailsColumn" style="width: 70%; padding: 20px;">
|
||||
<ui:Label name="TabTitle" text="GENERAL" style="font-size: 24px; -unity-font-style: bold; margin-bottom: 20px;" />
|
||||
<ui:ScrollView name="SettingsContent" style="flex-grow: 1;">
|
||||
<!-- Content will be injected here -->
|
||||
<!-- Content -->
|
||||
</ui:ScrollView>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -14,7 +14,7 @@ PlayerSettings:
|
||||
accelerometerFrequency: 60
|
||||
companyName: Scovania
|
||||
productName: HALLUCINATE
|
||||
defaultCursor: {fileID: 2800000, guid: bf03bd4e32f382f45bd848d91517f188, type: 3}
|
||||
defaultCursor: {fileID: 0}
|
||||
cursorHotspot: {x: 0, y: 0}
|
||||
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
||||
m_ShowUnitySplashScreen: 1
|
||||
@@ -40,7 +40,7 @@ PlayerSettings:
|
||||
width: 1
|
||||
height: 1
|
||||
m_SplashScreenLogos: []
|
||||
m_VirtualRealitySplashScreen: {fileID: 0}
|
||||
m_VirtualRealitySplashScreen: {fileID: 2800000, guid: 6eeaebf0e7047544cbe9984637a7a603, type: 3}
|
||||
m_HolographicTrackingLossScreen: {fileID: 0}
|
||||
defaultScreenWidth: 1024
|
||||
defaultScreenHeight: 768
|
||||
|
||||
Reference in New Issue
Block a user