Added new Monument preview display text variant

This commit is contained in:
r.nikolin 2023-10-25 13:46:39 +03:00
parent ccb7c8199e
commit 7c425e9638
14 changed files with 106 additions and 41 deletions

View File

@ -7,15 +7,15 @@ public class MonumentPreview : MonoBehaviour
{
[SerializeField] private Image _image;
[SerializeField] private UITextShow _UITextShow;
[SerializeField] private TextAutoscroll _textAutoscroll;
[SerializeField] private UIFader _UIFader;
[SerializeField] private TMPro.TextMeshProUGUI _nameText;
public void ShowInfo(string name, Sprite image, string text)
public void ShowInfo(string name, Sprite image, string text, float time)
{
_nameText.SetText(name);
_image.sprite = image;
_UITextShow.ShowSubtitle(text, 0, 5f, _UIFader.ShowPanel, _UIFader.HidePanel);
_UITextShow.SetText(text, time, _UIFader.ShowPanel, _UIFader.HidePanel);
_textAutoscroll.Scroll(time - 1);
}
}

View File

@ -33,7 +33,7 @@ public class MonumentPreviewController : MonoBehaviour
private void OnGrab(Grabber arg)
{
_monumentPreview.ShowInfo(_monumentMini.Info.Name, _monumentMini.Info.Image, _monumentMini.Info.Description);
_monumentPreview.ShowInfo(_monumentMini.Info.Name, _monumentMini.Info.Image, _monumentMini.Info.Description, _monumentMini.Info.ShortDuration);
_previewSound.PlaySound(_monumentMini.Info.ShortClip);
}

View File

@ -694,6 +694,7 @@ GameObject:
- component: {fileID: 3562124897911384411}
- component: {fileID: 2081165394880155475}
- component: {fileID: 4080531792993963957}
- component: {fileID: 4667959773318436821}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
@ -804,6 +805,19 @@ MonoBehaviour:
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &4667959773318436821
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2928323262731823328}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 435669f75d4652941b25e79977b925c0, type: 3}
m_Name:
m_EditorClassIdentifier:
_scrollbar: {fileID: 7428967782626760380}
--- !u!1 &2973316878502603538
GameObject:
m_ObjectHideFlags: 0
@ -1608,6 +1622,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
_image: {fileID: 5507942046738830429}
_UITextShow: {fileID: 8252726596294022789}
_textAutoscroll: {fileID: 4667959773318436821}
_UIFader: {fileID: 3356217451915231819}
_nameText: {fileID: 2431526707684633184}
--- !u!1 &4574774226115770231
@ -3941,19 +3956,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
OnTimeTick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 7428967782626760380}
m_TargetAssemblyTypeName: UnityEngine.UI.Scrollbar, UnityEngine.UI
m_MethodName: set_value
m_Mode: 4
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
OnTimeEnd:
m_PersistentCalls:
m_Calls: []
@ -11482,8 +11485,8 @@ RectTransform:
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: 4.29, y: -12.4}
m_SizeDelta: {x: 146.1, y: 16.6}
m_AnchoredPosition: {x: 3.8, y: -14.7}
m_SizeDelta: {x: 147.19, y: 16.6}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &73481480969909539
CanvasRenderer:
@ -11544,13 +11547,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 8
m_fontSize: 7.75
m_fontSizeBase: 9.67
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 8
m_fontSizeMin: 7
m_fontSizeMax: 15
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535

View File

@ -14946,7 +14946,7 @@ AudioSource:
m_Curve:
- serializedVersion: 3
time: 0
value: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0

View File

@ -61,3 +61,5 @@ MonoBehaviour:
Score: 50
ShortClip: {fileID: 8300000, guid: d973769c1bbe25c449a0ffe8e99219cb, type: 3}
LongClip: {fileID: 8300000, guid: 7f917b0e56a308542b1326460b7b7039, type: 3}
ShortDuration: 15
LongDuration: 50

View File

@ -62,3 +62,5 @@ MonoBehaviour:
Score: 50
ShortClip: {fileID: 8300000, guid: c6ce20be64be1494ab1b7862e2ff56c5, type: 3}
LongClip: {fileID: 8300000, guid: 29dfe8234ac048f458c3b2a886d76fde, type: 3}
ShortDuration: 12
LongDuration: 49

View File

@ -63,3 +63,5 @@ MonoBehaviour:
Score: 50
ShortClip: {fileID: 8300000, guid: c4ce7fc347531ea4ab62a9e87d475d40, type: 3}
LongClip: {fileID: 8300000, guid: 9e3bcaee60b08a5479e0432921d4f3eb, type: 3}
ShortDuration: 17
LongDuration: 44

View File

@ -24,8 +24,11 @@ MonoBehaviour:
\u0447\u0430\u0441\u0442\u043E \u043D\u0430\u0437\u044B\u0432\u0430\u044E\u0442
\u0433\u0430\u043B\u0435\u0440\u0435\u044E \r\n\xAB\u041C\u0430\u043B\u043E\u0439
\u0422\u0440\u0435\u0442\u044C\u044F\u043A\u043E\u0432\u043A\u043E\u0439\xBB."
LongDescription:
MiniModel: {fileID: 7721131150223155987, guid: 639d55772ac07cc4db41aff9b5fbb867,
type: 3}
Score: 50
ShortClip: {fileID: 8300000, guid: 29d1c2767dab7a944b241dc40ba86410, type: 3}
LongClip: {fileID: 8300000, guid: 1653025e88009de429f4677479ff73f7, type: 3}
ShortDuration: 13
LongDuration: 50

View File

@ -47,7 +47,7 @@ public class MonumentController : MonoBehaviour
public void PlaySound()
{
_previewSound.PlaySound(_info.LongClip);
_monumentPreview.ShowInfo(_info.Name, _info.Image, _info.LongDescription);
_monumentPreview.ShowInfo(_info.Name, _info.Image, _info.LongDescription, _info.LongDuration);
}
public void ShowPreview()

View File

@ -20,4 +20,7 @@ public class MonumentInfo : ScriptableObject
public AudioClip ShortClip;
public AudioClip LongClip;
public float ShortDuration = 5;
public float LongDuration = 5;
}

View File

@ -35,6 +35,15 @@ public class UITextShow : MonoBehaviour
SetText(num.ToString());
}
public void SetText(string text, float afterDelay, Action onStart, Action onEnd)
{
if (coroutine != null)
{
StopCoroutine(coroutine);
}
coroutine = StartCoroutine(SetText_Coroutine(text, afterDelay, onStart, onEnd));
}
public void ShowSubtitle(string text, float delay, float afterDelay, Action onStart, Action onEnd)
{
if (coroutine != null)
@ -89,4 +98,14 @@ public class UITextShow : MonoBehaviour
OnTimeEnd?.Invoke();
onEnd?.Invoke();
}
private IEnumerator SetText_Coroutine(string text, float afterDelay, Action onStart, Action onEnd)
{
onStart?.Invoke();
SetText(text);
yield return new WaitForSeconds(afterDelay);
SetText(string.Empty);
OnTimeEnd?.Invoke();
onEnd?.Invoke();
}
}

17
Assets/TextAutoscroll.cs Normal file
View File

@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextAutoscroll : MonoBehaviour
{
[SerializeField] private Scrollbar _scrollbar;
public void Scroll(float time)
{
LeanTween.value(1, 0, time).setDelay(1).setOnUpdate((float x) =>
{
_scrollbar.value = x;
}).setEaseInOutCubic();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 435669f75d4652941b25e79977b925c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -416,6 +416,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
_image: {fileID: 3985071509405579802}
_UITextShow: {fileID: 4779240040953172227}
_textAutoscroll: {fileID: 3094283400908279372}
_UIFader: {fileID: 1562700535410891397}
_nameText: {fileID: 2929830332299434188}
--- !u!1 &3686637382960672291
@ -640,13 +641,13 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 8
m_fontSize: 7.75
m_fontSizeBase: 9.67
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 8
m_fontSizeMin: 7
m_fontSizeMax: 15
m_fontStyle: 0
m_fontStyle: 1
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
@ -1651,19 +1652,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
OnTimeTick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 6090138090777650549}
m_TargetAssemblyTypeName: UnityEngine.UI.Scrollbar, UnityEngine.UI
m_MethodName: set_value
m_Mode: 4
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
OnTimeEnd:
m_PersistentCalls:
m_Calls: []
@ -1752,6 +1741,7 @@ GameObject:
- component: {fileID: 7910603277928972143}
- component: {fileID: 5220139661224149147}
- component: {fileID: 7208754759049997291}
- component: {fileID: 3094283400908279372}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
@ -1862,6 +1852,19 @@ MonoBehaviour:
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &3094283400908279372
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8131548603081972033}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 435669f75d4652941b25e79977b925c0, type: 3}
m_Name:
m_EditorClassIdentifier:
_scrollbar: {fileID: 6090138090777650549}
--- !u!1001 &645497833008328760
PrefabInstance:
m_ObjectHideFlags: 0