Created
February 3, 2021 15:47
-
-
Save kyubuns/59c5b76a6e33304860936a12166a7b53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using AnKuchen.KuchenLayout; | |
using AnKuchen.Map; | |
using Cysharp.Threading.Tasks; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class Quiz : MonoBehaviour | |
{ | |
public UICache titleUiCache; | |
public UICache quizUiCache; | |
public UICache resultUiCache; | |
public void Start() | |
{ | |
MainFlow().Forget(); | |
} | |
private async UniTask MainFlow() | |
{ | |
var titleUi = new TitleUiElements(titleUiCache); | |
var quizUi = new QuizUiElements(quizUiCache); | |
var resultUi = new ResultUiElements(resultUiCache); | |
titleUi.Root.SetActive(false); | |
quizUi.Root.SetActive(false); | |
resultUi.Root.SetActive(false); | |
while (true) | |
{ | |
// タイトル | |
titleUi.Root.SetActive(true); | |
await titleUi.StartButton.OnClickAsync(); | |
// クイズ | |
titleUi.Root.SetActive(false); | |
quizUi.Root.SetActive(true); | |
quizUi.QuizText.text = "世界で一番高い山は?"; | |
using (var editor = quizUi.SelectButtons.Edit()) | |
{ | |
var a = editor.Create(); | |
a.ButtonText.text = "富士山"; | |
var b = editor.Create(); | |
b.ButtonText.text = "K2"; | |
var c = editor.Create(); | |
c.ButtonText.text = "高尾山"; | |
var d = editor.Create(); | |
d.ButtonText.text = "六甲山"; | |
} | |
var index = await UniTask.WhenAny(quizUi.SelectButtons.Elements.Select(x => x.Button.OnClickAsync())); | |
// リザルト | |
quizUi.Root.SetActive(false); | |
resultUi.Root.SetActive(true); | |
resultUi.Maru.gameObject.SetActive(index == 0); | |
resultUi.Batu.gameObject.SetActive(index != 0); | |
await resultUi.ReturnButton.OnClickAsync(); | |
resultUi.Root.SetActive(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
アニメ入り版