Settings are now loaded from and saved to the config.json file. Reworked the UI structure a bit (the script that manage the settings have to be active before the UI is opened to actually take effect at game startup). Fixed several UI bugs (slider deselection, UI labels blocking the sliders, etc).
This commit is contained in:
@@ -119,7 +119,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!224 &2888630431832822380
|
--- !u!224 &2888630431832822380
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -128,7 +128,7 @@ RectTransform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 674832405591274748}
|
m_GameObject: {fileID: 674832405591274748}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 6.199966}
|
m_LocalPosition: {x: 0, y: 0, z: 6}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
@@ -137,8 +137,8 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: 198, y: 29.999985}
|
m_AnchoredPosition: {x: 25.8, y: -57.9}
|
||||||
m_SizeDelta: {x: 178.01, y: 338.4}
|
m_SizeDelta: {x: 485, y: 46.5}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &7009866660814900916
|
--- !u!222 &7009866660814900916
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
@@ -168,9 +168,7 @@ MonoBehaviour:
|
|||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: 'Warning:
|
m_text: High speeds may cause nausea!
|
||||||
|
|
||||||
High speeds may cause nausea'
|
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: d564a6b9a8a781b438125b614edcc297, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: d564a6b9a8a781b438125b614edcc297, type: 2}
|
||||||
m_sharedMaterial: {fileID: 2467261418627247352, guid: d564a6b9a8a781b438125b614edcc297,
|
m_sharedMaterial: {fileID: 2467261418627247352, guid: d564a6b9a8a781b438125b614edcc297,
|
||||||
@@ -205,7 +203,7 @@ MonoBehaviour:
|
|||||||
m_fontSizeMin: 18
|
m_fontSizeMin: 18
|
||||||
m_fontSizeMax: 72
|
m_fontSizeMax: 72
|
||||||
m_fontStyle: 0
|
m_fontStyle: 0
|
||||||
m_HorizontalAlignment: 1
|
m_HorizontalAlignment: 4
|
||||||
m_VerticalAlignment: 256
|
m_VerticalAlignment: 256
|
||||||
m_textAlignment: 65535
|
m_textAlignment: 65535
|
||||||
m_characterSpacing: 0
|
m_characterSpacing: 0
|
||||||
@@ -236,7 +234,7 @@ MonoBehaviour:
|
|||||||
m_VertexBufferAutoSizeReduction: 0
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
m_useMaxVisibleDescender: 1
|
m_useMaxVisibleDescender: 1
|
||||||
m_pageToDisplay: 1
|
m_pageToDisplay: 1
|
||||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
m_margin: {x: 1.8959656, y: 6.638962, z: 3.9048767, w: 1.7601442}
|
||||||
m_isUsingLegacyAnimationComponent: 0
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
m_isVolumetricText: 0
|
m_isVolumetricText: 0
|
||||||
m_hasFontAssetChanged: 0
|
m_hasFontAssetChanged: 0
|
||||||
@@ -582,6 +580,7 @@ Transform:
|
|||||||
- {fileID: 7867682990484010893}
|
- {fileID: 7867682990484010893}
|
||||||
- {fileID: 385502688868600332}
|
- {fileID: 385502688868600332}
|
||||||
- {fileID: 8911245181170312639}
|
- {fileID: 8911245181170312639}
|
||||||
|
- {fileID: 4369549003892251738}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
@@ -711,8 +710,8 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: -371.7, y: 0.000015258789}
|
m_AnchoredPosition: {x: -429.3, y: 0.000015258789}
|
||||||
m_SizeDelta: {x: 469.55, y: 50.48}
|
m_SizeDelta: {x: 319.7, y: 50.48}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &1756154180137300123
|
--- !u!222 &1756154180137300123
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
@@ -808,7 +807,7 @@ MonoBehaviour:
|
|||||||
m_VertexBufferAutoSizeReduction: 0
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
m_useMaxVisibleDescender: 1
|
m_useMaxVisibleDescender: 1
|
||||||
m_pageToDisplay: 1
|
m_pageToDisplay: 1
|
||||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
m_margin: {x: 2.8457031, y: 0, z: 2.8460312, w: 0}
|
||||||
m_isUsingLegacyAnimationComponent: 0
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
m_isVolumetricText: 0
|
m_isVolumetricText: 0
|
||||||
m_hasFontAssetChanged: 0
|
m_hasFontAssetChanged: 0
|
||||||
@@ -1140,6 +1139,129 @@ RectTransform:
|
|||||||
m_AnchoredPosition: {x: -5.404525, y: 60.661545}
|
m_AnchoredPosition: {x: -5.404525, y: 60.661545}
|
||||||
m_SizeDelta: {x: 100, y: 100}
|
m_SizeDelta: {x: 100, y: 100}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!1 &1647071810007517722
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 4369549003892251738}
|
||||||
|
- component: {fileID: 18611445735460691}
|
||||||
|
- component: {fileID: 8343075384873062513}
|
||||||
|
- component: {fileID: 5285357331933866282}
|
||||||
|
- component: {fileID: 1310480035629572623}
|
||||||
|
- component: {fileID: 1510780549024052800}
|
||||||
|
- component: {fileID: 4307275810096043329}
|
||||||
|
m_Layer: 12
|
||||||
|
m_Name: Settings
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &4369549003892251738
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1647071810007517722}
|
||||||
|
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: 5343771095006709614}
|
||||||
|
m_RootOrder: -1
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &18611445735460691
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1647071810007517722}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 26a0dd79a025e5041a41f576b1aa4968, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
turnOffButton: {fileID: 3645818974320619446}
|
||||||
|
turnOnButton: {fileID: 1311809556432207317}
|
||||||
|
moveSpeedSlider: {fileID: 6956878155406096985}
|
||||||
|
locomotion: {fileID: 1565464911732960072}
|
||||||
|
--- !u!114 &8343075384873062513
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1647071810007517722}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
target: 0
|
||||||
|
slider: {fileID: 7370795858478176567}
|
||||||
|
--- !u!114 &5285357331933866282
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1647071810007517722}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
target: 3
|
||||||
|
slider: {fileID: 8524569723447833986}
|
||||||
|
--- !u!114 &1310480035629572623
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1647071810007517722}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
target: 5
|
||||||
|
slider: {fileID: 3954205046647893400}
|
||||||
|
--- !u!114 &1510780549024052800
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1647071810007517722}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
target: 4
|
||||||
|
slider: {fileID: 7262865820799039206}
|
||||||
|
--- !u!114 &4307275810096043329
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1647071810007517722}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
target: 1
|
||||||
|
slider: {fileID: 512852062931003448}
|
||||||
--- !u!1 &1694677102371321062
|
--- !u!1 &1694677102371321062
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2219,7 +2341,6 @@ GameObject:
|
|||||||
- component: {fileID: 5495779272626688296}
|
- component: {fileID: 5495779272626688296}
|
||||||
- component: {fileID: 270386226070323618}
|
- component: {fileID: 270386226070323618}
|
||||||
- component: {fileID: 7370795858478176567}
|
- component: {fileID: 7370795858478176567}
|
||||||
- component: {fileID: 9192465668386235667}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Button
|
m_Name: Button
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -2346,19 +2467,6 @@ MonoBehaviour:
|
|||||||
minValue: 0
|
minValue: 0
|
||||||
maxValue: 1
|
maxValue: 1
|
||||||
slideareaOffsetMultiplier: 0.9
|
slideareaOffsetMultiplier: 0.9
|
||||||
--- !u!114 &9192465668386235667
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 3421967330093517364}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
target: 0
|
|
||||||
--- !u!1 &3434260850308121859
|
--- !u!1 &3434260850308121859
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2412,7 +2520,6 @@ GameObject:
|
|||||||
- component: {fileID: 5857106340495004348}
|
- component: {fileID: 5857106340495004348}
|
||||||
- component: {fileID: 467034009919322666}
|
- component: {fileID: 467034009919322666}
|
||||||
- component: {fileID: 3954205046647893400}
|
- component: {fileID: 3954205046647893400}
|
||||||
- component: {fileID: 8737582689073729793}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Button
|
m_Name: Button
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -2539,19 +2646,6 @@ MonoBehaviour:
|
|||||||
minValue: 0
|
minValue: 0
|
||||||
maxValue: 1
|
maxValue: 1
|
||||||
slideareaOffsetMultiplier: 0.9
|
slideareaOffsetMultiplier: 0.9
|
||||||
--- !u!114 &8737582689073729793
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 3504227185401202113}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
target: 5
|
|
||||||
--- !u!1 &3847096334227967442
|
--- !u!1 &3847096334227967442
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -3036,7 +3130,7 @@ RectTransform:
|
|||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: -1849.8, y: 30}
|
m_AnchoredPosition: {x: -1849.8, y: 30}
|
||||||
m_SizeDelta: {x: 90.1, y: 50.5}
|
m_SizeDelta: {x: 89, y: 50.5}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &1344781521441133505
|
--- !u!222 &1344781521441133505
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
@@ -3539,7 +3633,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: -2404.8, y: 34.7}
|
m_AnchoredPosition: {x: -2600, y: 34.7}
|
||||||
m_SizeDelta: {x: 220, y: 49.6}
|
m_SizeDelta: {x: 220, y: 49.6}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &2306375091028476275
|
--- !u!222 &2306375091028476275
|
||||||
@@ -3605,7 +3699,7 @@ MonoBehaviour:
|
|||||||
m_fontSizeMin: 18
|
m_fontSizeMin: 18
|
||||||
m_fontSizeMax: 72
|
m_fontSizeMax: 72
|
||||||
m_fontStyle: 0
|
m_fontStyle: 0
|
||||||
m_HorizontalAlignment: 1
|
m_HorizontalAlignment: 4
|
||||||
m_VerticalAlignment: 512
|
m_VerticalAlignment: 512
|
||||||
m_textAlignment: 65535
|
m_textAlignment: 65535
|
||||||
m_characterSpacing: 0
|
m_characterSpacing: 0
|
||||||
@@ -3636,7 +3730,7 @@ MonoBehaviour:
|
|||||||
m_VertexBufferAutoSizeReduction: 0
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
m_useMaxVisibleDescender: 1
|
m_useMaxVisibleDescender: 1
|
||||||
m_pageToDisplay: 1
|
m_pageToDisplay: 1
|
||||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
m_margin: {x: 14.186401, y: 0, z: -0.9451599, w: 0}
|
||||||
m_isUsingLegacyAnimationComponent: 0
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
m_isVolumetricText: 0
|
m_isVolumetricText: 0
|
||||||
m_hasFontAssetChanged: 0
|
m_hasFontAssetChanged: 0
|
||||||
@@ -3655,7 +3749,6 @@ GameObject:
|
|||||||
- component: {fileID: 4467346825075014904}
|
- component: {fileID: 4467346825075014904}
|
||||||
- component: {fileID: 1078020185355697329}
|
- component: {fileID: 1078020185355697329}
|
||||||
- component: {fileID: 7262865820799039206}
|
- component: {fileID: 7262865820799039206}
|
||||||
- component: {fileID: 8463522706283787556}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Button
|
m_Name: Button
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -3782,19 +3875,6 @@ MonoBehaviour:
|
|||||||
minValue: 0
|
minValue: 0
|
||||||
maxValue: 1
|
maxValue: 1
|
||||||
slideareaOffsetMultiplier: 0.9
|
slideareaOffsetMultiplier: 0.9
|
||||||
--- !u!114 &8463522706283787556
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5731468542189211806}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
target: 4
|
|
||||||
--- !u!1 &5770108565631511295
|
--- !u!1 &5770108565631511295
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -5429,13 +5509,14 @@ MonoBehaviour:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 6798620428918177696}
|
m_GameObject: {fileID: 6798620428918177696}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 26a0dd79a025e5041a41f576b1aa4968, type: 3}
|
m_Script: {fileID: 11500000, guid: 26a0dd79a025e5041a41f576b1aa4968, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
turnOffButton: {fileID: 3645818974320619446}
|
turnOffButton: {fileID: 3645818974320619446}
|
||||||
turnOnButton: {fileID: 1311809556432207317}
|
turnOnButton: {fileID: 1311809556432207317}
|
||||||
|
moveSpeedSlider: {fileID: 6956878155406096985}
|
||||||
locomotion: {fileID: 1565464911732960072}
|
locomotion: {fileID: 1565464911732960072}
|
||||||
--- !u!1 &6976341305452677775
|
--- !u!1 &6976341305452677775
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -5463,7 +5544,7 @@ RectTransform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 6976341305452677775}
|
m_GameObject: {fileID: 6976341305452677775}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 1.0000267}
|
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
@@ -5472,8 +5553,8 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: -406.48022, y: 260}
|
m_AnchoredPosition: {x: -446.3, y: 255.3}
|
||||||
m_SizeDelta: {x: 383.04, y: 50.5}
|
m_SizeDelta: {x: 327.3, y: 50.5}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &8334943640923905114
|
--- !u!222 &8334943640923905114
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
@@ -5569,7 +5650,7 @@ MonoBehaviour:
|
|||||||
m_VertexBufferAutoSizeReduction: 0
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
m_useMaxVisibleDescender: 1
|
m_useMaxVisibleDescender: 1
|
||||||
m_pageToDisplay: 1
|
m_pageToDisplay: 1
|
||||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
m_margin: {x: 0, y: 0, z: 0.9477234, w: 0}
|
||||||
m_isUsingLegacyAnimationComponent: 0
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
m_isVolumetricText: 0
|
m_isVolumetricText: 0
|
||||||
m_hasFontAssetChanged: 0
|
m_hasFontAssetChanged: 0
|
||||||
@@ -5625,7 +5706,6 @@ GameObject:
|
|||||||
- component: {fileID: 7392776148620295955}
|
- component: {fileID: 7392776148620295955}
|
||||||
- component: {fileID: 623723497249906612}
|
- component: {fileID: 623723497249906612}
|
||||||
- component: {fileID: 8524569723447833986}
|
- component: {fileID: 8524569723447833986}
|
||||||
- component: {fileID: 2518031444015721236}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Button
|
m_Name: Button
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -5752,19 +5832,6 @@ MonoBehaviour:
|
|||||||
minValue: 0
|
minValue: 0
|
||||||
maxValue: 1
|
maxValue: 1
|
||||||
slideareaOffsetMultiplier: 0.9
|
slideareaOffsetMultiplier: 0.9
|
||||||
--- !u!114 &2518031444015721236
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 7116268483853744053}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
target: 3
|
|
||||||
--- !u!1 &7137625347935658456
|
--- !u!1 &7137625347935658456
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -6850,7 +6917,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: -2404.8, y: 30}
|
m_AnchoredPosition: {x: -2424, y: 30}
|
||||||
m_SizeDelta: {x: 186.1, y: 50.5}
|
m_SizeDelta: {x: 186.1, y: 50.5}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &6159749963066026057
|
--- !u!222 &6159749963066026057
|
||||||
@@ -6916,7 +6983,7 @@ MonoBehaviour:
|
|||||||
m_fontSizeMin: 18
|
m_fontSizeMin: 18
|
||||||
m_fontSizeMax: 72
|
m_fontSizeMax: 72
|
||||||
m_fontStyle: 0
|
m_fontStyle: 0
|
||||||
m_HorizontalAlignment: 1
|
m_HorizontalAlignment: 4
|
||||||
m_VerticalAlignment: 512
|
m_VerticalAlignment: 512
|
||||||
m_textAlignment: 65535
|
m_textAlignment: 65535
|
||||||
m_characterSpacing: 0
|
m_characterSpacing: 0
|
||||||
@@ -6966,7 +7033,6 @@ GameObject:
|
|||||||
- component: {fileID: 4806540607707404536}
|
- component: {fileID: 4806540607707404536}
|
||||||
- component: {fileID: 1263225200033619485}
|
- component: {fileID: 1263225200033619485}
|
||||||
- component: {fileID: 512852062931003448}
|
- component: {fileID: 512852062931003448}
|
||||||
- component: {fileID: 5185990981600041478}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Button
|
m_Name: Button
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -7093,19 +7159,6 @@ MonoBehaviour:
|
|||||||
minValue: 0
|
minValue: 0
|
||||||
maxValue: 1
|
maxValue: 1
|
||||||
slideareaOffsetMultiplier: 0.9
|
slideareaOffsetMultiplier: 0.9
|
||||||
--- !u!114 &5185990981600041478
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 7795711801980221647}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: ebe1ab889a9bed940995d4f47bc743ef, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
target: 1
|
|
||||||
--- !u!1 &7941339244779152679
|
--- !u!1 &7941339244779152679
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -7851,7 +7904,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
m_AnchoredPosition: {x: -3755, y: 30}
|
m_AnchoredPosition: {x: -3897, y: 30}
|
||||||
m_SizeDelta: {x: 131.9, y: 50.5}
|
m_SizeDelta: {x: 131.9, y: 50.5}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &7891019527381773321
|
--- !u!222 &7891019527381773321
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
abstract public class AbstractSlider : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
public RectTransform sliderBackground; // Assign in Inspector
|
||||||
|
public float minValue = 0f;
|
||||||
|
public float maxValue = 1f;
|
||||||
|
public float slideareaOffsetMultiplier = 0.9f;
|
||||||
|
public float CurrentValue { get; private set; }
|
||||||
|
public float CurrentNormalizedValue { get; private set; }
|
||||||
|
|
||||||
|
private RectTransform handleRect;
|
||||||
|
private Vector2 backgroundStart;
|
||||||
|
private float backgroundWidth;
|
||||||
|
|
||||||
|
public System.Action<float, bool> OnValueChanged;
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
if (null == handleRect)
|
||||||
|
{
|
||||||
|
handleRect = GetComponent<RectTransform>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sliderBackground != null)
|
||||||
|
{
|
||||||
|
backgroundStart = sliderBackground.position;
|
||||||
|
backgroundWidth = sliderBackground.rect.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateHandlePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual public void OnBeginDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
UpdateSlider(eventData);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual public void OnDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
UpdateSlider(eventData);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual public void OnEndDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
UpdateSlider(eventData, true);
|
||||||
|
EventSystem.current.SetSelectedGameObject(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual public void SetHandleValue(float unnormalizedValue)
|
||||||
|
{
|
||||||
|
SetValuesFromValue(unnormalizedValue);
|
||||||
|
UpdateHandlePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual public void SetHandleNormalizedValue(float normalizedValue)
|
||||||
|
{
|
||||||
|
SetValuesFromNormalizedValue(normalizedValue);
|
||||||
|
UpdateHandlePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual protected void UpdateHandlePosition()
|
||||||
|
{
|
||||||
|
if (null == handleRect) return; // The options menu might not be opened yet
|
||||||
|
|
||||||
|
float halfWidth = sliderBackground.rect.width * 0.5f;
|
||||||
|
float limit = halfWidth * slideareaOffsetMultiplier;
|
||||||
|
|
||||||
|
float x = Mathf.Lerp(-limit, limit, CurrentNormalizedValue);
|
||||||
|
handleRect.localPosition = new Vector3(x, handleRect.localPosition.y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual protected void UpdateSlider(PointerEventData eventData, bool draggingEnded = false)
|
||||||
|
{
|
||||||
|
Vector2 localPoint;
|
||||||
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(sliderBackground, eventData.position, eventData.pressEventCamera, out localPoint);
|
||||||
|
float halfWidth = sliderBackground.rect.width * 0.5f;
|
||||||
|
|
||||||
|
// Only allow dragging within 90% of the slider width, centered
|
||||||
|
float limit = halfWidth * slideareaOffsetMultiplier;
|
||||||
|
float clampedX = Mathf.Clamp(localPoint.x, -limit, limit);
|
||||||
|
|
||||||
|
|
||||||
|
Vector3 newPosition = new Vector3(clampedX, handleRect.localPosition.y, handleRect.localPosition.z);
|
||||||
|
handleRect.localPosition = newPosition;
|
||||||
|
|
||||||
|
// Normalize within the limited 90% range
|
||||||
|
float normalized = (clampedX + limit) / (limit * 2f);
|
||||||
|
SetValuesFromValue(Mathf.Lerp(minValue, maxValue, normalized));
|
||||||
|
|
||||||
|
OnValueChanged?.Invoke(CurrentValue, draggingEnded);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetValuesFromNormalizedValue(float normalizedValue)
|
||||||
|
{
|
||||||
|
CurrentNormalizedValue = normalizedValue;
|
||||||
|
CurrentValue = CurrentNormalizedValue * (maxValue - minValue) + minValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetValuesFromValue(float unnormalizedValue)
|
||||||
|
{
|
||||||
|
CurrentValue = unnormalizedValue;
|
||||||
|
CurrentNormalizedValue = (CurrentValue - minValue) / (maxValue - minValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8fe704cafb6cf2441a62a6497d58f229
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -4,87 +4,8 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
public class AudioSliderDragHandler : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
public class AudioSliderDragHandler : AbstractSlider, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public RectTransform sliderBackground; // Assign in Inspector
|
|
||||||
public float minValue = 0f;
|
|
||||||
public float maxValue = 1f;
|
|
||||||
public float slideareaOffsetMultiplier = 0.9f;
|
|
||||||
public float CurrentValue { get; private set; }
|
|
||||||
|
|
||||||
private RectTransform handleRect;
|
|
||||||
private Vector2 backgroundStart;
|
|
||||||
private float backgroundWidth;
|
|
||||||
|
|
||||||
public System.Action<float> OnValueChanged;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
handleRect = GetComponent<RectTransform>();
|
|
||||||
|
|
||||||
if (sliderBackground != null)
|
|
||||||
{
|
|
||||||
backgroundStart = sliderBackground.position;
|
|
||||||
backgroundWidth = sliderBackground.rect.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnBeginDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
UpdateSlider(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetHandlePosition(float normalizedValue)
|
|
||||||
{
|
|
||||||
float halfWidth = sliderBackground.rect.width * 0.5f;
|
|
||||||
float limit = halfWidth * slideareaOffsetMultiplier;
|
|
||||||
|
|
||||||
float x = Mathf.Lerp(-limit, limit, normalizedValue);
|
|
||||||
handleRect.localPosition = new Vector3(x, handleRect.localPosition.y, 0);
|
|
||||||
|
|
||||||
CurrentValue = normalizedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void OnDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
UpdateSlider(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnEndDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
UpdateSlider(eventData);
|
|
||||||
//notify FMOD
|
|
||||||
}
|
|
||||||
private void UpdateSlider(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
|
|
||||||
//Debug.Log("UpDating Slider");
|
|
||||||
Vector2 localPoint;
|
|
||||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(sliderBackground, eventData.position, eventData.pressEventCamera, out localPoint);
|
|
||||||
|
|
||||||
float halfWidth = sliderBackground.rect.width * 0.5f;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Only allow dragging within 90% of the slider width, centered
|
|
||||||
float limit = halfWidth * slideareaOffsetMultiplier;
|
|
||||||
float clampedX = Mathf.Clamp(localPoint.x, -limit, limit);
|
|
||||||
|
|
||||||
Vector3 newPosition = new Vector3(clampedX, handleRect.localPosition.y, handleRect.localPosition.z);
|
|
||||||
handleRect.localPosition = newPosition;
|
|
||||||
|
|
||||||
// Normalize within the limited 90% range
|
|
||||||
float normalized = (clampedX + limit) / (limit * 2f);
|
|
||||||
//Debug.Log(normalized);
|
|
||||||
CurrentValue = Mathf.Lerp(minValue, maxValue, normalized);
|
|
||||||
|
|
||||||
//Debug.Log(warningThreshholdValue);
|
|
||||||
OnValueChanged?.Invoke(CurrentValue);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public Button turnOffButton;
|
public Button turnOffButton;
|
||||||
public Button turnOnButton;
|
public Button turnOnButton;
|
||||||
|
public MoveSliderDragHandler moveSpeedSlider;
|
||||||
public ContinuousMoveProviderBase locomotion;
|
public ContinuousMoveProviderBase locomotion;
|
||||||
|
|
||||||
// Events for listeners
|
// Events for listeners
|
||||||
@@ -19,13 +20,21 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
|
|||||||
{
|
{
|
||||||
turnOnButton.onClick.AddListener(enableLocomotion);
|
turnOnButton.onClick.AddListener(enableLocomotion);
|
||||||
turnOffButton.onClick.AddListener(disableLocomotion);
|
turnOffButton.onClick.AddListener(disableLocomotion);
|
||||||
turnOffButton.gameObject.SetActive(false);
|
|
||||||
|
bool isContinuousLocomotion = ConfigManager.instance.GetIsContinuousLocomotion();
|
||||||
|
turnOffButton.gameObject.SetActive(isContinuousLocomotion);
|
||||||
|
locomotion.enabled = isContinuousLocomotion;
|
||||||
|
|
||||||
|
float continuousLocomotionSpeed = ConfigManager.instance.GetContinuousLocomotionSpeed();
|
||||||
|
moveSpeedSlider.SetHandleValue(continuousLocomotionSpeed);
|
||||||
|
locomotion.moveSpeed = continuousLocomotionSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSpeed(float speed)
|
public void UpdateSpeed(float speed)
|
||||||
{
|
{
|
||||||
locomotion.moveSpeed = speed;
|
locomotion.moveSpeed = speed;
|
||||||
OnSpeedChanged?.Invoke(speed);
|
OnSpeedChanged?.Invoke(speed);
|
||||||
|
WriteToConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableLocomotion()
|
private void enableLocomotion()
|
||||||
@@ -35,6 +44,7 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
|
|||||||
turnOnButton.gameObject.SetActive(false);
|
turnOnButton.gameObject.SetActive(false);
|
||||||
turnOffButton.gameObject.SetActive(true);
|
turnOffButton.gameObject.SetActive(true);
|
||||||
OnLocomotionToggled?.Invoke(true);
|
OnLocomotionToggled?.Invoke(true);
|
||||||
|
WriteToConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableLocomotion()
|
private void disableLocomotion()
|
||||||
@@ -44,5 +54,12 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
|
|||||||
turnOnButton.gameObject.SetActive(true);
|
turnOnButton.gameObject.SetActive(true);
|
||||||
turnOffButton.gameObject.SetActive(false);
|
turnOffButton.gameObject.SetActive(false);
|
||||||
OnLocomotionToggled?.Invoke(false);
|
OnLocomotionToggled?.Invoke(false);
|
||||||
|
WriteToConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void WriteToConfig()
|
||||||
|
{
|
||||||
|
ConfigManager.instance.SetIsContinuousLocomotion(locomotion.enabled);
|
||||||
|
ConfigManager.instance.SetContinuousLocomotionSpeed(locomotion.moveSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,82 +3,35 @@ using UnityEngine.UI;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
public class MoveSliderDragHandler : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler
|
public class MoveSliderDragHandler : AbstractSlider, IDragHandler, IBeginDragHandler, IEndDragHandler
|
||||||
{
|
{
|
||||||
public RectTransform sliderBackground; // Assign in Inspector
|
|
||||||
public float minValue = 2f;
|
|
||||||
public float maxValue = 5f;
|
|
||||||
public float slideareaOffsetMultiplier = 0.9f;
|
|
||||||
public TMP_Text warningText;
|
public TMP_Text warningText;
|
||||||
public float warningThreshholdValue = 0.65f;
|
public float warningThreshholdValue = 0.65f;
|
||||||
public float CurrentValue { get; private set; }
|
|
||||||
|
|
||||||
public ContinuoslocomotionConfigurator configurator;
|
public ContinuoslocomotionConfigurator configurator;
|
||||||
|
|
||||||
private RectTransform handleRect;
|
override public void OnEndDrag(PointerEventData eventData)
|
||||||
private Vector2 backgroundStart;
|
|
||||||
private float backgroundWidth;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
{
|
||||||
handleRect = GetComponent<RectTransform>();
|
base.OnEndDrag(eventData);
|
||||||
|
|
||||||
if (sliderBackground != null)
|
|
||||||
{
|
|
||||||
backgroundStart = sliderBackground.position;
|
|
||||||
backgroundWidth = sliderBackground.rect.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnBeginDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
UpdateSlider(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
UpdateSlider(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnEndDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
UpdateSlider(eventData);
|
|
||||||
configurator.UpdateSpeed(CurrentValue);
|
configurator.UpdateSpeed(CurrentValue);
|
||||||
|
|
||||||
EventSystem.current.SetSelectedGameObject(null);
|
|
||||||
}
|
}
|
||||||
private void UpdateSlider(PointerEventData eventData)
|
|
||||||
|
override protected void UpdateSlider(PointerEventData eventData, bool draggingEnded = false)
|
||||||
{
|
{
|
||||||
Debug.Log("UpDating Slider");
|
base.UpdateSlider(eventData, draggingEnded);
|
||||||
Vector2 localPoint;
|
DisplayWarningTextIfNecessary();
|
||||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(sliderBackground, eventData.position, eventData.pressEventCamera, out localPoint);
|
}
|
||||||
|
|
||||||
float halfWidth = sliderBackground.rect.width * 0.5f;
|
override protected void UpdateHandlePosition()
|
||||||
|
{
|
||||||
|
base.UpdateHandlePosition();
|
||||||
|
DisplayWarningTextIfNecessary();
|
||||||
// Only allow dragging within 90% of the slider width, centered
|
}
|
||||||
float limit = halfWidth * slideareaOffsetMultiplier;
|
|
||||||
float clampedX = Mathf.Clamp(localPoint.x, -limit, limit);
|
|
||||||
|
|
||||||
Vector3 newPosition = new Vector3(clampedX, handleRect.localPosition.y, handleRect.localPosition.z);
|
|
||||||
handleRect.localPosition = newPosition;
|
|
||||||
|
|
||||||
// Normalize within the limited 90% range
|
|
||||||
float normalized = (clampedX + limit) / (limit * 2f);
|
|
||||||
//Debug.Log(normalized);
|
|
||||||
CurrentValue = Mathf.Lerp(minValue, maxValue, normalized);
|
|
||||||
|
|
||||||
// Displaying the warning.
|
|
||||||
|
|
||||||
|
protected void DisplayWarningTextIfNecessary()
|
||||||
|
{
|
||||||
if (CurrentValue > (warningThreshholdValue * (maxValue - minValue) + minValue)) warningText.gameObject.SetActive(true);
|
if (CurrentValue > (warningThreshholdValue * (maxValue - minValue) + minValue)) warningText.gameObject.SetActive(true);
|
||||||
|
|
||||||
else warningText.gameObject.SetActive(false);
|
else warningText.gameObject.SetActive(false);
|
||||||
|
|
||||||
//Debug.Log(warningThreshholdValue);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,36 +13,35 @@ public class SliderToVCA : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
public VCATarget target;
|
public VCATarget target;
|
||||||
private AudioSliderDragHandler slider;
|
public AudioSliderDragHandler slider;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
slider = GetComponent<AudioSliderDragHandler>();
|
|
||||||
slider.OnValueChanged += ApplyVolume;
|
slider.OnValueChanged += ApplyVolume;
|
||||||
}
|
}
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
float initialValue = GetInitialValueFromAudioManager();
|
float initialValue = GetInitialValue();
|
||||||
slider.SetHandlePosition(initialValue); // we will add this function
|
slider.SetHandleValue(initialValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private float GetInitialValueFromAudioManager()
|
private float GetInitialValue()
|
||||||
{
|
{
|
||||||
switch (target)
|
switch (target)
|
||||||
{
|
{
|
||||||
case VCATarget.Master:
|
case VCATarget.Master:
|
||||||
return AudioManager.Instance.MasterVolume;
|
return ConfigManager.instance.getVolumeMaster();
|
||||||
case VCATarget.Ambiences:
|
case VCATarget.Ambiences:
|
||||||
return AudioManager.Instance.AmbienceVolume;
|
return ConfigManager.instance.getVolumeAmbient();
|
||||||
case VCATarget.Music:
|
case VCATarget.Music:
|
||||||
return AudioManager.Instance.MusicVolume;
|
return ConfigManager.instance.getVolumeMusic();
|
||||||
case VCATarget.SFX:
|
case VCATarget.SFX:
|
||||||
return AudioManager.Instance.SFXVolume;
|
return ConfigManager.instance.getVolumeSFX();
|
||||||
case VCATarget.UI:
|
case VCATarget.UI:
|
||||||
return AudioManager.Instance.UIVolume;
|
return ConfigManager.instance.getVolumeUI();
|
||||||
case VCATarget.Voiceovers:
|
case VCATarget.Voiceovers:
|
||||||
return AudioManager.Instance.VoiceoverVolume;
|
return ConfigManager.instance.getVolumeVO();
|
||||||
default:
|
default:
|
||||||
return 0.5f;
|
return 0.5f;
|
||||||
}
|
}
|
||||||
@@ -51,38 +50,44 @@ private float GetInitialValueFromAudioManager()
|
|||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
// Constantly push slider value to the VCA
|
// Constantly push slider value to the VCA
|
||||||
ApplyVolume(slider.CurrentValue);
|
ApplyVolume(slider.CurrentValue, false);
|
||||||
//Debug.Log("CurrentValue: " + slider.CurrentValue);
|
//Debug.Log("CurrentValue: " + slider.CurrentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyVolume(float value)
|
private void ApplyVolume(float value, bool isLastChange)
|
||||||
{
|
{
|
||||||
switch (target)
|
switch (target)
|
||||||
{
|
{
|
||||||
case VCATarget.Master:
|
case VCATarget.Master:
|
||||||
AudioManager.Instance.SetMasterVCA(value);
|
AudioManager.Instance.SetMasterVCA(value);
|
||||||
//Debug.LogError(value);
|
if (isLastChange) ConfigManager.instance.SetVolumeMaster(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VCATarget.Ambiences:
|
case VCATarget.Ambiences:
|
||||||
AudioManager.Instance.SetAmbientVCA(value);
|
AudioManager.Instance.SetAmbientVCA(value);
|
||||||
|
if (isLastChange) ConfigManager.instance.SetVolumeAmbient(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VCATarget.Music:
|
case VCATarget.Music:
|
||||||
AudioManager.Instance.SetMusicVCA(value);
|
AudioManager.Instance.SetMusicVCA(value);
|
||||||
|
if (isLastChange) ConfigManager.instance.SetVolumeMusic(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VCATarget.SFX:
|
case VCATarget.SFX:
|
||||||
AudioManager.Instance.SetSFXVCA(value);
|
AudioManager.Instance.SetSFXVCA(value);
|
||||||
|
if (isLastChange) ConfigManager.instance.SetVolumeSFX(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VCATarget.UI:
|
case VCATarget.UI:
|
||||||
AudioManager.Instance.SetUIVCA(value);
|
AudioManager.Instance.SetUIVCA(value);
|
||||||
|
if (isLastChange) ConfigManager.instance.SetVolumeUI(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VCATarget.Voiceovers:
|
case VCATarget.Voiceovers:
|
||||||
AudioManager.Instance.SetVoiceoverVCA(value);
|
AudioManager.Instance.SetVoiceoverVCA(value);
|
||||||
|
if (isLastChange) ConfigManager.instance.SetVolumeVO(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using FishNet.Component.Spawning;
|
using FishNet.Component.Spawning;
|
||||||
using SimpleJSON;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Valve.Newtonsoft.Json;
|
using Valve.Newtonsoft.Json;
|
||||||
|
using static ConfigManager;
|
||||||
|
|
||||||
public class ConfigManager : MonoBehaviour
|
public class ConfigManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -14,8 +14,15 @@ public class ConfigManager : MonoBehaviour
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class Config
|
public class Config
|
||||||
{
|
{
|
||||||
public bool isContinuousLocomotion;
|
public bool isContinuousLocomotion = false;
|
||||||
public float masterVolume;
|
public float continuousLocomotionSpeed = 0.5f;
|
||||||
|
public float volumeMaster = 0.5f;
|
||||||
|
public float volumeAmbient = 0.5f;
|
||||||
|
public float volumeMusic = 0.5f;
|
||||||
|
public float volumeSFX = 0.5f;
|
||||||
|
public float volumeUI = 0.5f;
|
||||||
|
public float volumeVO = 0.5f;
|
||||||
|
|
||||||
}
|
}
|
||||||
protected Config currentConfig = new Config();
|
protected Config currentConfig = new Config();
|
||||||
protected string configFileName = "config.json";
|
protected string configFileName = "config.json";
|
||||||
@@ -48,15 +55,18 @@ public class ConfigManager : MonoBehaviour
|
|||||||
if (!File.Exists(configFilePath))
|
if (!File.Exists(configFilePath))
|
||||||
{
|
{
|
||||||
fileStream = File.Create(configFilePath);
|
fileStream = File.Create(configFilePath);
|
||||||
|
fileStream.Close();
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
fileStream = new FileStream(configFilePath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
|
//fileStream = new FileStream(configFilePath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
StreamWriter writer = new StreamWriter(fileStream);
|
//StreamWriter writer = new StreamWriter(fileStream);
|
||||||
writer.Write(JsonUtility.ToJson(currentConfig));
|
//writer.Write(JsonUtility.ToJson(currentConfig));
|
||||||
writer.Close();
|
//writer.Close();
|
||||||
fileStream.Close();
|
//fileStream.Close();
|
||||||
|
string json = JsonUtility.ToJson(currentConfig, true);
|
||||||
|
File.WriteAllText(configFilePath, json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,21 +78,16 @@ public class ConfigManager : MonoBehaviour
|
|||||||
if (!File.Exists(configFilePath))
|
if (!File.Exists(configFilePath))
|
||||||
{
|
{
|
||||||
Debug.LogError("Config file was not found and could not be created: " + configFilePath);
|
Debug.LogError("Config file was not found and could not be created: " + configFilePath);
|
||||||
return null;
|
return currentConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Config config = JsonUtility.FromJson<Config>(File.ReadAllText(configFilePath));
|
||||||
|
|
||||||
|
/*FileStream fileStream = new FileStream(configFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
FileStream fileStream = new FileStream(configFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
||||||
StreamReader reader = new StreamReader(fileStream);
|
StreamReader reader = new StreamReader(fileStream);
|
||||||
Config config = JsonUtility.FromJson<Config>(reader.ReadToEnd());
|
Config config = JsonUtility.FromJson<Config>(reader.ReadToEnd());
|
||||||
reader.Close();
|
reader.Close();
|
||||||
fileStream.Close();
|
fileStream.Close();*/
|
||||||
|
|
||||||
//Config config = JsonUtility.FromJson<Config>(File.ReadAllText(configFilePath));
|
|
||||||
|
|
||||||
Debug.Log(config.isContinuousLocomotion);
|
|
||||||
Debug.Log(config.masterVolume);
|
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -106,15 +111,80 @@ public class ConfigManager : MonoBehaviour
|
|||||||
SaveConfigToFile();
|
SaveConfigToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetContinuousLocomotionSpeed()
|
||||||
public float getMasterVolume()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return currentConfig.masterVolume;
|
return currentConfig.continuousLocomotionSpeed;
|
||||||
}
|
}
|
||||||
public void SetMasterVolume(float masterVolume)
|
public void SetContinuousLocomotionSpeed(float continuousLocomotionSpeed)
|
||||||
{
|
{
|
||||||
currentConfig.masterVolume = masterVolume;
|
currentConfig.continuousLocomotionSpeed = continuousLocomotionSpeed;
|
||||||
|
SaveConfigToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVolumeMaster()
|
||||||
|
{
|
||||||
|
|
||||||
|
return currentConfig.volumeMaster;
|
||||||
|
}
|
||||||
|
public void SetVolumeMaster(float masterVolume)
|
||||||
|
{
|
||||||
|
currentConfig.volumeMaster = masterVolume;
|
||||||
|
SaveConfigToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVolumeAmbient()
|
||||||
|
{
|
||||||
|
|
||||||
|
return currentConfig.volumeAmbient;
|
||||||
|
}
|
||||||
|
public void SetVolumeAmbient(float ambientVolume)
|
||||||
|
{
|
||||||
|
currentConfig.volumeAmbient = ambientVolume;
|
||||||
|
SaveConfigToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVolumeMusic()
|
||||||
|
{
|
||||||
|
|
||||||
|
return currentConfig.volumeMusic;
|
||||||
|
}
|
||||||
|
public void SetVolumeMusic(float musicVolume)
|
||||||
|
{
|
||||||
|
currentConfig.volumeMusic = musicVolume;
|
||||||
|
SaveConfigToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVolumeSFX()
|
||||||
|
{
|
||||||
|
|
||||||
|
return currentConfig.volumeSFX;
|
||||||
|
}
|
||||||
|
public void SetVolumeSFX(float sfxVolume)
|
||||||
|
{
|
||||||
|
currentConfig.volumeSFX = sfxVolume;
|
||||||
|
SaveConfigToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVolumeUI()
|
||||||
|
{
|
||||||
|
|
||||||
|
return currentConfig.volumeUI;
|
||||||
|
}
|
||||||
|
public void SetVolumeUI(float uiVolume)
|
||||||
|
{
|
||||||
|
currentConfig.volumeUI = uiVolume;
|
||||||
|
SaveConfigToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVolumeVO()
|
||||||
|
{
|
||||||
|
|
||||||
|
return currentConfig.volumeVO;
|
||||||
|
}
|
||||||
|
public void SetVolumeVO(float voVolume)
|
||||||
|
{
|
||||||
|
currentConfig.volumeVO = voVolume;
|
||||||
SaveConfigToFile();
|
SaveConfigToFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user