From 07be95d901b9c04bd273598c509dd014498c75b0 Mon Sep 17 00:00:00 2001 From: sega Date: Thu, 20 Aug 2026 17:30:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=81=D0=B2=D0=B5=D1=80=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D1=8B.=20=D0=A3=D1=80=D0=B0...=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/BaseSettingView.cs | 4 + Assets/MSignalButton.cs | 62 +++++-- Assets/NewSettingViews/SignalSetting.prefab | 2 +- Assets/Scenes/GameScene3D.unity | 177 +++++++++++++++++++- Assets/Scripts/Settings/SettingsScreen.cs | 49 ++++-- Assets/Scripts/Settings/Views/BoolView.cs | 2 +- Assets/Scripts/Settings/Views/FloatView.cs | 2 +- Assets/Scripts/Settings/Views/IntView.cs | 2 +- Assets/Scripts/Settings/Views/SignalView.cs | 7 + Assets/Scripts/Settings/Views/StringView.cs | 2 +- Assets/SignalButton.prefab | 8 +- 11 files changed, 275 insertions(+), 42 deletions(-) diff --git a/Assets/BaseSettingView.cs b/Assets/BaseSettingView.cs index 0a5022b..5706d05 100644 --- a/Assets/BaseSettingView.cs +++ b/Assets/BaseSettingView.cs @@ -5,6 +5,10 @@ public abstract class BaseSettingView : MonoBehaviour { public RectTransform pivotPoint; [SerializeField] private TextMeshProUGUI _settingNameLabel; + public abstract SettingDTO CachedSetting { get; set; } + + public virtual void Select() { } + public virtual void Deselect() { } public virtual void Initialize(SettingDTO setting) { diff --git a/Assets/MSignalButton.cs b/Assets/MSignalButton.cs index 74ffb9e..8f46482 100644 --- a/Assets/MSignalButton.cs +++ b/Assets/MSignalButton.cs @@ -1,5 +1,7 @@ using DG.Tweening; using System; +using TMPro; +using TMPro.EditorUtilities; using UnityEngine; using UnityEngine.UI; @@ -8,7 +10,9 @@ public class MSignalButton : MonoBehaviour public event Action OnClick; [SerializeField] private Image _image; + [SerializeField] TextMeshProUGUI _textMeshPro; [SerializeField] private Color _normalColor; + [SerializeField] private Color _selectedColor; [SerializeField] private Color _pressedColor; [SerializeField] private AudioClip _clip; @@ -21,29 +25,59 @@ public class MSignalButton : MonoBehaviour { if (pressed) { - OnClick?.Invoke(); - PlayAnimation(); + + ClickAnimation(); } _lastPressed = pressed; } } - public void PlayAnimation() + public void ClickAnimation() + { + StopAnimation(); + + _animation = DOTween.Sequence(); + + _animation.Append(_image.DOColor(_pressedColor, 0.15f)); + _animation.Append(_image.DOColor(_selectedColor, 0.15f)); + _animation.AppendCallback(() => + { + OnClick?.Invoke(); + SoundManager.instance.playClip(_clip); + }); + + _animation.PlayForward(); + } + + public void SelectAnimation() + { + StopAnimation(); + + _animation = DOTween.Sequence(); + _animation.Append(_image.DOColor(_selectedColor, 0.3f)); + _animation.Join(_textMeshPro.DOColor(Color.black, 0.3f)); + _animation.PlayForward(); + } + + public void DeselectAnimation() + { + StopAnimation(); + + //_animation = DOTween.Sequence(); + //_animation.Append(_image.DOColor(_normalColor, 0.1f)); + //_animation.Join(_textMeshPro.DOColor(Color.white, 0.3f)); + //_animation.PlayForward(); + + _image.color = _normalColor; + _textMeshPro.color = Color.white; + } + + private void StopAnimation() { if (_animation != null) { _animation.Kill(); _animation = null; } - - _animation = DOTween.Sequence(); - - _animation.Append(_image.DOColor(_pressedColor, 0.1f)); - _animation.AppendCallback(() => SoundManager.instance.playClip(_clip)); - _animation.Append(_image.DOColor(_normalColor, 0.1f)); - - _animation.PlayForward(); } - - -} +} \ No newline at end of file diff --git a/Assets/NewSettingViews/SignalSetting.prefab b/Assets/NewSettingViews/SignalSetting.prefab index e14ba54..c92fae0 100644 --- a/Assets/NewSettingViews/SignalSetting.prefab +++ b/Assets/NewSettingViews/SignalSetting.prefab @@ -94,7 +94,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchoredPosition: {x: -29.9, y: 0} m_SizeDelta: {x: 2, y: 63.02} m_Pivot: {x: 0, y: 0.5} --- !u!1001 &520807226183219737 diff --git a/Assets/Scenes/GameScene3D.unity b/Assets/Scenes/GameScene3D.unity index 289b0bc..290f1cf 100644 --- a/Assets/Scenes/GameScene3D.unity +++ b/Assets/Scenes/GameScene3D.unity @@ -3229,6 +3229,82 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!1 &183166104 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 183166105} + - component: {fileID: 183166107} + - component: {fileID: 183166106} + m_Layer: 5 + m_Name: Scrollbar + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &183166105 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 183166104} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1450075491} + m_Father: {fileID: 1922048923} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 201.9, y: -34} + m_SizeDelta: {x: 12.4, y: 680} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &183166106 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 183166104} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 0.29411766, g: 0.29411766, b: 0.29411766, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + 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!222 &183166107 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 183166104} + m_CullTransparentMesh: 1 --- !u!1 &183404321 GameObject: m_ObjectHideFlags: 0 @@ -6719,6 +6795,7 @@ GameObject: - component: {fileID: 435572913} - component: {fileID: 435572915} - component: {fileID: 435572914} + - component: {fileID: 435572916} m_Layer: 5 m_Name: highlight m_TagString: Untagged @@ -6783,6 +6860,18 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 435572912} m_CullTransparentMesh: 1 +--- !u!225 &435572916 +CanvasGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 435572912} + m_Enabled: 1 + m_Alpha: 1 + m_Interactable: 1 + m_BlocksRaycasts: 1 + m_IgnoreParentGroups: 0 --- !u!1 &436763672 GameObject: m_ObjectHideFlags: 0 @@ -9053,12 +9142,15 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: GroupPrefab: {fileID: 0} - testPointer: {fileID: 0} + _testPointer: {fileID: 0} + _pointerCG: {fileID: 0} scrollRect: {fileID: 0} + _description: {fileID: 0} switchAxis: 1 interactAxis: 1 intractButton: 4 Content: {fileID: 0} + _scrollBar: {fileID: 0} --- !u!1 &584665084 GameObject: m_ObjectHideFlags: 0 @@ -22045,6 +22137,81 @@ Transform: m_Children: [] m_Father: {fileID: 151433695} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1450075490 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1450075491} + - component: {fileID: 1450075493} + - component: {fileID: 1450075492} + m_Layer: 5 + m_Name: Bar + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1450075491 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1450075490} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 183166105} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 1} + m_AnchorMax: {x: 0.5, y: 1} + m_AnchoredPosition: {x: 0, y: -460} + m_SizeDelta: {x: 12, y: 220} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &1450075492 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1450075490} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 0.9686275, g: 0.9215687, b: 0.23529413, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + 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!222 &1450075493 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1450075490} + m_CullTransparentMesh: 1 --- !u!1 &1462487492 GameObject: m_ObjectHideFlags: 0 @@ -23569,7 +23736,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 10.445006, y: 0.0000003874302} + m_AnchoredPosition: {x: 10.445007, y: 0.0000003874302} m_SizeDelta: {x: 20.89, y: 24.69} m_Pivot: {x: 1, y: 0.5} --- !u!114 &1558714549 @@ -29598,6 +29765,7 @@ RectTransform: - {fileID: 730497169} - {fileID: 266292069} - {fileID: 1980776983} + - {fileID: 183166105} m_Father: {fileID: 1967587903} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} @@ -30314,12 +30482,15 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Assembly-CSharp::SettingsScreen GroupPrefab: {fileID: 1011650303975809369, guid: 9368f9b18ede1664e94d2d1304998bc5, type: 3} - testPointer: {fileID: 1642698354} + _testPointer: {fileID: 1642698354} + _pointerCG: {fileID: 435572916} scrollRect: {fileID: 1980776984} + _description: {fileID: 266292070} switchAxis: 1 interactAxis: 0 intractButton: 4 Content: {fileID: 1843853773} + _scrollBar: {fileID: 1450075491} --- !u!1 &1967870042 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Settings/SettingsScreen.cs b/Assets/Scripts/Settings/SettingsScreen.cs index 7591fd4..5288751 100644 --- a/Assets/Scripts/Settings/SettingsScreen.cs +++ b/Assets/Scripts/Settings/SettingsScreen.cs @@ -1,5 +1,5 @@ -using System.Buffers.Text; -using System.Collections.Generic; +using System.Collections.Generic; +using TMPro; using UnityEngine; using UnityEngine.UI; @@ -8,40 +8,57 @@ public class SettingsScreen : MonoBehaviour [Header("Ссылки")] [SerializeField] private SettingGroup GroupPrefab; - private bool Generated = false; - private int activeSetting; + private int activeSettingIndex; private List settings; - [SerializeField] RectTransform testPointer; + [SerializeField] RectTransform _testPointer; + [SerializeField] CanvasGroup _pointerCG; [SerializeField] ScrollRect scrollRect; + [SerializeField] TextMeshProUGUI _description; - - //==================== [Header("Управление")] [SerializeField] private Axis switchAxis = Axis.Vertical; [SerializeField] private Axis interactAxis = Axis.Horizontal; [SerializeField] private PlayerAction intractButton = PlayerAction.action; [SerializeField] private RectTransform Content; + [SerializeField] RectTransform _scrollBar; + private BaseSettingView SelectedSetting => settings[activeSettingIndex]; private void Start() { Generate(); + UpdatePointer(); } private void Update() { int switchDirection = -In.GetAxis(switchAxis, JoystickSide.Both); - - activeSetting = (activeSetting + switchDirection + settings.Count) % settings.Count; + if (switchDirection != 0) + { + SelectedSetting.Deselect(); + activeSettingIndex = (activeSettingIndex + switchDirection + settings.Count) % settings.Count; + SelectedSetting.Select(); + _description.text = SelectedSetting.CachedSetting.Description; - var activePivot = settings[activeSetting].pivotPoint; - ScrollToElementVertical(activePivot); - testPointer.position = activePivot.position; + UpdatePointer(); + } int interactDirection = In.GetAxis(interactAxis, JoystickSide.Both, InteractMode.Continious); - settings[activeSetting].TakeInput(interactDirection, false); + bool action = In.GetButtonAnyPlayer(PlayerAction.action); + SelectedSetting.TakeInput(interactDirection, action); + } + + private void UpdatePointer() + { + var activePivot = SelectedSetting.pivotPoint; + ScrollToElementVertical(activePivot); + _testPointer.position = activePivot.position; + _pointerCG.alpha = SelectedSetting is SignalView ? 0 : 1; + + _scrollBar.anchoredPosition = new Vector2(0, -460f * activeSettingIndex / (settings.Count-1)); + } public void Generate() @@ -52,8 +69,7 @@ public class SettingsScreen : MonoBehaviour foreach (var group in SettingsManager.currentSchemeDTO.groups) settings.AddRange(GenerateGroup(group).settings); - activeSetting = 0; - Generated = true; + activeSettingIndex = 0; } private SettingGroup GenerateGroup(SettingsGroupDTO groupData) @@ -78,7 +94,7 @@ public class SettingsScreen : MonoBehaviour } LayoutRebuilder.ForceRebuildLayoutImmediate(scrollRect.content); - + RectTransform viewport = scrollRect.viewport; RectTransform content = scrollRect.content; @@ -112,5 +128,4 @@ public class SettingsScreen : MonoBehaviour scrollRect.verticalNormalizedPosition = newPosition; } - } \ No newline at end of file diff --git a/Assets/Scripts/Settings/Views/BoolView.cs b/Assets/Scripts/Settings/Views/BoolView.cs index bd37943..540d190 100644 --- a/Assets/Scripts/Settings/Views/BoolView.cs +++ b/Assets/Scripts/Settings/Views/BoolView.cs @@ -5,7 +5,7 @@ public class BoolView : BaseSettingView [SerializeField] private MToggle _toggle; public bool Value { get; private set; } - public SettingDTO CachedSetting { get; private set; } + public override SettingDTO CachedSetting { get; set; } public override void Initialize(SettingDTO setting) { diff --git a/Assets/Scripts/Settings/Views/FloatView.cs b/Assets/Scripts/Settings/Views/FloatView.cs index a1faf9c..934dd1e 100644 --- a/Assets/Scripts/Settings/Views/FloatView.cs +++ b/Assets/Scripts/Settings/Views/FloatView.cs @@ -13,7 +13,7 @@ public class FloatView : BaseSettingView private float delta; private float step; - public SettingDTO CachedSetting { get; private set; } + public override SettingDTO CachedSetting { get; set; } public override void Initialize(SettingDTO setting) { diff --git a/Assets/Scripts/Settings/Views/IntView.cs b/Assets/Scripts/Settings/Views/IntView.cs index 6ece83d..e092a3c 100644 --- a/Assets/Scripts/Settings/Views/IntView.cs +++ b/Assets/Scripts/Settings/Views/IntView.cs @@ -8,7 +8,7 @@ public class IntView : BaseSettingView [SerializeField] private AudioClip SwitchClip; [SerializeField] private AudioSource Source; - public SettingDTO CachedSetting { get; private set; } + public override SettingDTO CachedSetting { get; set; } public override void Initialize(SettingDTO setting) { diff --git a/Assets/Scripts/Settings/Views/SignalView.cs b/Assets/Scripts/Settings/Views/SignalView.cs index 25a3eaf..af81af1 100644 --- a/Assets/Scripts/Settings/Views/SignalView.cs +++ b/Assets/Scripts/Settings/Views/SignalView.cs @@ -8,14 +8,21 @@ public class SignalView : BaseSettingView [SerializeField] private MSignalButton _signalButton; private string signal; + public override SettingDTO CachedSetting { get ; set; } + public override void Initialize(SettingDTO setting) { base.Initialize(setting); + CachedSetting = setting; signal = setting.SignalValue; _signalButton.OnClick += EmitSignal; } public override void TakeInput(int _, bool action) => _signalButton.TakeInput(action); + public override void Select() => _signalButton.SelectAnimation(); + + public override void Deselect() => _signalButton.DeselectAnimation(); + private void EmitSignal() => SignalEmmited?.Invoke(signal); } \ No newline at end of file diff --git a/Assets/Scripts/Settings/Views/StringView.cs b/Assets/Scripts/Settings/Views/StringView.cs index e15d2d4..84339b9 100644 --- a/Assets/Scripts/Settings/Views/StringView.cs +++ b/Assets/Scripts/Settings/Views/StringView.cs @@ -5,7 +5,7 @@ public class StringView : BaseSettingView [SerializeField] MStringStepper _stepper; [SerializeField] private AudioClip SwitchClip; - public SettingDTO CachedSetting { get; private set; } + public override SettingDTO CachedSetting { get; set; } public override void Initialize(SettingDTO setting) { diff --git a/Assets/SignalButton.prefab b/Assets/SignalButton.prefab index 2d01661..f702e7c 100644 --- a/Assets/SignalButton.prefab +++ b/Assets/SignalButton.prefab @@ -199,7 +199,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image m_Material: {fileID: 0} - m_Color: {r: 0.972549, g: 0.91764706, b: 0.23529412, a: 1} + m_Color: {r: 0.690566, g: 0.690566, b: 0.690566, a: 1} m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 0 @@ -229,6 +229,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Assembly-CSharp::MSignalButton _image: {fileID: 3946266212054413381} - _normalColor: {r: 0.972549, g: 0.91764706, b: 0.23529412, a: 1} - _pressedColor: {r: 0.6301887, g: 0.5941508, b: 0.14625129, a: 1} + _textMeshPro: {fileID: 2090018479069457630} + _normalColor: {r: 0.40392157, g: 0.40392157, b: 0.40392157, a: 1} + _selectedColor: {r: 0.972549, g: 0.91764706, b: 0.23529412, a: 1} + _pressedColor: {r: 1, g: 1, b: 1, a: 1} _clip: {fileID: 8300000, guid: 1c48900c9ab0aa8418920a8193050870, type: 3}