게임매니저 없이 패널 테스트 기능

게임 매니저를 호출하지 않고 패널을 테스트할 수 있게 기능을 분리
This commit is contained in:
99jamin 2025-03-16 20:34:14 +09:00
parent b742c6a009
commit df06252f26
11 changed files with 114 additions and 37 deletions

View File

@ -67,8 +67,8 @@ MonoBehaviour:
m_Calls: []
m_text: messege text
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -334,8 +334,8 @@ MonoBehaviour:
m_Calls: []
m_text: Button
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []

View File

@ -65,10 +65,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Name
m_text: "\uC774\uB984"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -201,8 +201,8 @@ MonoBehaviour:
m_Calls: []
m_text: 00:00:00
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -491,3 +491,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 446a80ba82242004eb31339c44f8ac3b, type: 3}
m_Name:
m_EditorClassIdentifier:
profileSprites:
- {fileID: 21300000, guid: edeacd6d8f6ab0d42bbdf4ada3c61a27, type: 3}

View File

@ -65,10 +65,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: name
m_text: "\uC774\uB984"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -199,10 +199,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: winRate
m_text: "\uC2B9\uB960"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -491,3 +491,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e2c72577a3d9f7b479c7bac6a8f65048, type: 3}
m_Name:
m_EditorClassIdentifier:
profileSprites:
- {fileID: 21300000, guid: 2d325c545f7c9144cb37a45e93e5ddb9, type: 3}
- {fileID: 21300000, guid: 59492a1d9c2719641bd0d4d53988c9b4, type: 3}

View File

@ -67,8 +67,8 @@ MonoBehaviour:
m_Calls: []
m_text: 6COIN
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -199,10 +199,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Price
m_text: "1000\uC6D0"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -491,3 +491,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4d28917ad20c19e428cbf98ba5609e69, type: 3}
m_Name:
m_EditorClassIdentifier:
profileSprites:
- {fileID: 21300000, guid: 307bff9630735f342852f28b1cd5d300, type: 3}

View File

@ -310,10 +310,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: BGM
m_text: "\uBC30\uACBD\uC74C\uC545"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@ -1233,10 +1233,10 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: SFX
m_text: "\uD6A8\uACFC\uC74C"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []

View File

@ -294,6 +294,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 03aef985a8b802a409630fdcab7be09b, type: 3}
m_Name:
m_EditorClassIdentifier:
settingsPanel: {fileID: 2861881646994438329, guid: ea820246b5075c54d9f614291ca41c5d, type: 3}
confirmPanel: {fileID: 8145365568262946399, guid: 76f1fe6b5243faf4f9b8caee7312d336, type: 3}
rankingPanel: {fileID: 154459105952450598, guid: bf4bb18aa323fe748b3eb1d537503596, type: 3}
shopPanel: {fileID: 8190964574954487140, guid: eb257b0a685b2254f860f294ce8cba54, type: 3}
giboPanel: {fileID: 3090474328172188941, guid: c63914e01332f8d479ada92325335e41, type: 3}
_canvas: {fileID: 6741227126671320411}
--- !u!222 &71273024816384741
CanvasRenderer:
m_ObjectHideFlags: 0

View File

@ -21,7 +21,6 @@ public class GameManager : Singleton<GameManager>
private StoneController _stoneController;
private Canvas _canvas;
public Sprite[] profileSprites; //스크롤 패널에서 사용할 테스트 배열
private void Awake()
{

View File

@ -7,6 +7,7 @@ using UnityEngine.UI;
public class GiboItemController : MonoBehaviour
{
GiboItem _giboItem;
public Sprite[] profileSprites;
public void Init(GiboItem giboItem)
{
_giboItem = giboItem;
@ -14,7 +15,7 @@ public class GiboItemController : MonoBehaviour
var itemImage = GetComponentsInChildren<Image>()[1];
var itemText = GetComponentsInChildren<TextMeshProUGUI>();
itemImage.sprite = GameManager.Instance.profileSprites[this._giboItem.WinLoseSpriteIndex];
itemImage.sprite = profileSprites[this._giboItem.WinLoseSpriteIndex];
itemText[0].text = this._giboItem.Date;
itemText[1].text = this._giboItem.Name;
}

View File

@ -7,13 +7,15 @@ using UnityEngine.UI;
public class RankingItemController : MonoBehaviour
{
RankingItem _rankingItem;
public Sprite[] profileSprites;
public void Init(RankingItem rankingItem)
{
_rankingItem = rankingItem;
var itemImage = GetComponentsInChildren<Image>()[1];
var itemText = GetComponentsInChildren<TextMeshProUGUI>();
itemImage.sprite = GameManager.Instance.profileSprites[this._rankingItem.ProfileSpriteIndex];
itemImage.sprite = profileSprites[this._rankingItem.ProfileSpriteIndex];
itemText[0].text = this._rankingItem.Name;
itemText[1].text = this._rankingItem.WinRate.ToString();
}

View File

@ -7,13 +7,15 @@ using UnityEngine.UI;
public class ShopItemController : MonoBehaviour
{
ShopItem _shopItem;
public Sprite[] profileSprites;
public void Init(ShopItem shopItem)
{
_shopItem = shopItem;
var itemImage = GetComponentsInChildren<Image>()[1];
var itemText = GetComponentsInChildren<TextMeshProUGUI>();
itemImage.sprite = GameManager.Instance.profileSprites[this._shopItem.ItemSpriteIndex];
itemImage.sprite = profileSprites[this._shopItem.ItemSpriteIndex];
itemText[0].text = this._shopItem.Name;
itemText[1].text = this._shopItem.Price;
}

View File

@ -11,20 +11,78 @@ using Random = UnityEngine.Random;
/// </summary>
public class TestPanelController : MonoBehaviour
{
//게임매니저 없이 동작하도록 작성한 테스트 코드
[SerializeField] private GameObject settingsPanel;
[SerializeField] private GameObject confirmPanel;
[SerializeField] private GameObject rankingPanel;
[SerializeField] private GameObject shopPanel;
[SerializeField] private GameObject giboPanel;
public Canvas _canvas;
public void OpenConfirmPanel(string message, ConfirmPanelController.OnConfirmButtonClick onConfirmButtonClick)
{
if (_canvas != null)
{
var confirmPanelObject = Instantiate(confirmPanel, _canvas.transform);
confirmPanelObject.GetComponent<ConfirmPanelController>()
.Show(message, onConfirmButtonClick);
}
}
public void OpenSettingsPanel()
{
if (_canvas != null)
{
var settingsPanelObject = Instantiate(settingsPanel, _canvas.transform);
settingsPanelObject.GetComponent<PanelController>().Show();
}
}
public void OpenRankingPanel(List<RankingItem> rankingItems)
{
if (_canvas != null)
{
var settingsPanelObject = Instantiate(rankingPanel, _canvas.transform);
settingsPanelObject.GetComponent<RankingPanelController>().Show(rankingItems);
}
}
public void OpenShopPanel(List<ShopItem> shopItems)
{
if (_canvas != null)
{
var settingsPanelObject = Instantiate(shopPanel, _canvas.transform);
settingsPanelObject.GetComponent<ShopPanelController>().Show(shopItems);
}
}
public void OpenGiboPanel(List<GiboItem> giboItems)
{
if (_canvas != null)
{
var settingsPanelObject = Instantiate(giboPanel, _canvas.transform);
settingsPanelObject.GetComponent<GiboPanelController>().Show(giboItems);
}
}
//확인 패널 생성
public void OnConfirmPanelClick()
{
GameManager.Instance.OpenConfirmPanel("확인 패널 입니다.", () =>
OpenConfirmPanel("확인 패널 입니다.", () =>
{
Debug.Log("확인 버튼을 누르셨습니다.");
});
return;
}
//세팅 패널 생성
public void OnSettingPanelClick()
{
GameManager.Instance.OpenSettingsPanel();
OpenSettingsPanel();
}
//랭킹 패널 생성
public void OnRankingPanelClick()
{
@ -40,9 +98,10 @@ public class TestPanelController : MonoBehaviour
rankingItems.Add(rankingItem);
}
GameManager.Instance.OpenRankingPanel(rankingItems);
OpenRankingPanel(rankingItems);
}
//상점 패널 생성
public void OnShopPanelClick()
{
@ -51,16 +110,17 @@ public class TestPanelController : MonoBehaviour
{
ShopItem shopItem = new ShopItem
{
ItemSpriteIndex = Random.Range(0, 2),
ItemSpriteIndex = Random.Range(0, 1),
Name = i.ToString(),
Price = (i * 1000)+ "원"
};
shopItems.Add(shopItem);
}
GameManager.Instance.OpenShopPanel(shopItems);
OpenShopPanel(shopItems);
}
//기보 패널 생성
public void OnGiboPanelClick()
{
@ -69,7 +129,7 @@ public class TestPanelController : MonoBehaviour
{
GiboItem giboItem = new GiboItem
{
WinLoseSpriteIndex = Random.Range(0, 2),
WinLoseSpriteIndex = Random.Range(0, 1),
Date = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
Name = i.ToString(),
};
@ -77,7 +137,7 @@ public class TestPanelController : MonoBehaviour
giboItems.Add(giboItem);
}
GameManager.Instance.OpenGiboPanel(giboItems);
OpenGiboPanel(giboItems);
}