リザルト表示対応

This commit is contained in:
kimura 2022-07-20 16:41:16 +09:00
parent 0e965dc4c2
commit 1087dc51c2
5 changed files with 132 additions and 43 deletions

View File

@ -334,6 +334,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 6683278606952877351}
- component: {fileID: 8433642066964592433}
m_Layer: 5
m_Name: Achievement
m_TagString: Untagged
@ -364,6 +365,21 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 873, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8433642066964592433
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7875260906630132135}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: aecbe374740f4c85b6d1801d9883ecfb, type: 3}
m_Name:
m_EditorClassIdentifier:
scoreText: {fileID: 2632606540025123801}
amountText: {fileID: 2297321579623685580}
imageTarget: {fileID: 7791682651809340974}
--- !u!1001 &7982488480579137169
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -11,7 +11,8 @@ GameObject:
- component: {fileID: 3779557953680873011}
- component: {fileID: 6699140437324939704}
- component: {fileID: 6525861985503286921}
- component: {fileID: 7405638171975199055}
- component: {fileID: 1881795417845868589}
- component: {fileID: 5763692680617305610}
m_Layer: 5
m_Name: Scrollbar Vertical
m_TagString: Untagged
@ -37,9 +38,9 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: -17}
m_Pivot: {x: 1, y: 0}
m_AnchoredPosition: {x: -17, y: 0}
m_SizeDelta: {x: 17, y: 20}
m_Pivot: {x: 0, y: 0}
--- !u!222 &6699140437324939704
CanvasRenderer:
m_ObjectHideFlags: 0
@ -78,7 +79,7 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &7405638171975199055
--- !u!114 &1881795417845868589
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -87,7 +88,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1714705491346765828}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2a4db7a114972834c8e4117be1d82ba3, type: 3}
m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
@ -118,15 +119,32 @@ MonoBehaviour:
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 6882608199208682986}
m_TargetGraphic: {fileID: 6525861985503286921}
m_FillRect: {fileID: 0}
m_HandleRect: {fileID: 1649908109064974666}
m_Direction: 3
m_Value: 1
m_Size: 0.5833333
m_NumberOfSteps: 0
m_MinValue: 0
m_MaxValue: 1
m_WholeNumbers: 0
m_Value: 0
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &5763692680617305610
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1714705491346765828}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4c7fb96966974f86a04af9747989d1f9, type: 3}
m_Name:
m_EditorClassIdentifier:
scrollRect: {fileID: 6640995362510587213}
verticalSlider: {fileID: 1881795417845868589}
direction: 2
--- !u!1 &2636382713276872719
GameObject:
m_ObjectHideFlags: 0
@ -163,9 +181,9 @@ RectTransform:
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_SizeDelta: {x: -17, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!222 &7322984285357220499
CanvasRenderer:
@ -1435,7 +1453,9 @@ MonoBehaviour:
retryButton: {fileID: 5034752974366649370}
meterProgressImage: {fileID: 5034752975781299947}
meterProgressText: {fileID: 5034752974341280191}
materialNameText: {fileID: 0}
scrollRect: {fileID: 6640995362510587213}
itemPrefab: {fileID: 8433642066964592433, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
materialImageTarget: {fileID: 5034752974552429102}
materialAmountText: {fileID: 5034752974931089885}
scoreText: {fileID: 3075952525041976627}
@ -2354,7 +2374,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Content: {fileID: 7408749182440553541}
m_Horizontal: 1
m_Horizontal: 0
m_Vertical: 1
m_MovementType: 1
m_Elasticity: 0.1
@ -2363,7 +2383,7 @@ MonoBehaviour:
m_ScrollSensitivity: 1
m_Viewport: {fileID: 2022167647526899616}
m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 7405638171975199055}
m_VerticalScrollbar: {fileID: 0}
m_HorizontalScrollbarVisibility: 2
m_VerticalScrollbarVisibility: 2
m_HorizontalScrollbarSpacing: -3
@ -2599,7 +2619,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: -20}
m_SizeDelta: {x: 0, y: -20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7568597037811004154
GameObject:
@ -2753,7 +2773,7 @@ MonoBehaviour:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 8cb7ad5a6b78a6448b6fac7e77282a9d, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
@ -7744,7 +7764,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -7754,7 +7774,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -7804,12 +7824,12 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 466.5
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -550
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8034,7 +8054,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8044,7 +8064,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8094,12 +8114,12 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 466.5
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -350
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8184,7 +8204,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8194,7 +8214,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8244,12 +8264,12 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 466.5
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -250
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8334,7 +8354,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8344,7 +8364,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8394,12 +8414,12 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 466.5
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -50
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8484,7 +8504,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8494,7 +8514,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8544,12 +8564,12 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 466.5
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -450
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8634,7 +8654,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8644,7 +8664,7 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
@ -8694,12 +8714,12 @@ PrefabInstance:
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 466.5
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -150
objectReference: {fileID: 0}
- target: {fileID: 6683278606952877351, guid: be7c15cb2f923744e907b7d95b5d6f74,
type: 3}

View File

@ -0,0 +1,20 @@
using UnityEngine;
using UnityEngine.UI;
namespace MyGame.Scenes.MiniGame.Scripts
{
public class ResultItem : MonoBehaviour
{
[SerializeField] private Text scoreText;
[SerializeField] private Text amountText;
[SerializeField] private Transform imageTarget;
public void SetData(int needScore, int amount, Transform imagePrefab)
{
scoreText.text = string.Format("スコア{0}達成", needScore);
amountText.text = string.Format("×{0}", amount);
imageTarget.DestroyAllChildrens();
Instantiate(imagePrefab, imageTarget);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aecbe374740f4c85b6d1801d9883ecfb
timeCreated: 1658295145

View File

@ -17,7 +17,8 @@ namespace MyGame.Scenes.MiniGame.Scripts
[SerializeField] private Button retryButton;
[SerializeField] private Image meterProgressImage;
[SerializeField] private TextMeshProUGUI meterProgressText;
[SerializeField] private Text materialNameText;
[SerializeField] private ScrollRect scrollRect;
[SerializeField] private ResultItem itemPrefab;
[SerializeField] private Transform materialImageTarget;
[SerializeField] private Text materialAmountText;
[SerializeField] private Text scoreText;
@ -75,7 +76,36 @@ namespace MyGame.Scenes.MiniGame.Scripts
var shopData = shopDataList.FirstOrDefault(data => data.itemId == placeData.itemId && data.Category == ItemCategory.Material);
materialImageTarget.DestroyAllChildrens();
Instantiate(shopData.GetIconPrefab(), materialImageTarget);
materialAmountText.text = $"x{amount}";
scrollRect.content.DestroyAllChildrens();
var amount = 0;
var needScores = placeData.NeedScores;
foreach (var needScore in needScores[..^1])
{
if (score < needScore)
{
break;
}
// add score
var item = Instantiate(itemPrefab, scrollRect.content);
item.SetData(needScore, 1, shopData.GetIconPrefab());
amount++;
}
var maxScore = needScores[^2];
var scoreStep = needScores[^1];
if (score > maxScore)
{
foreach (var needScore in Enumerable.Range(1, Mathf.FloorToInt((float)(score - maxScore) / scoreStep)))
{
// add score
var item = Instantiate(itemPrefab, scrollRect.content);
item.SetData(maxScore + needScore * scoreStep, 1, shopData.GetIconPrefab());
amount++;
}
}
materialAmountText.text = $"×{amount}";
Shopping.AddItem(shopData, amount);
}