Skip to content

Commit acbefa4

Browse files
committed
Add more sample code
1 parent bfbb59b commit acbefa4

File tree

6 files changed

+3150
-0
lines changed

6 files changed

+3150
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
4+
public class TestDialogBox : UiDialog
5+
{
6+
public Text Message;
7+
public InputField Input;
8+
9+
public override void OnShow(object param)
10+
{
11+
Message.text = (string)param;
12+
Input.text = "";
13+
}
14+
15+
public void OnOkButtonClick()
16+
{
17+
Hide(Input.text);
18+
}
19+
}

src/UnityPackage/Assets/Middleware/UiManagerSample/TestDialogBox.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using Common.Logging;
2+
using System.Collections;
3+
using UnityEngine;
4+
5+
public class UiManagerSample : MonoBehaviour
6+
{
7+
protected ILog _logger = LogManager.GetLogger("UiManagerSample");
8+
9+
protected void Awake()
10+
{
11+
UiManager.Initialize();
12+
}
13+
14+
public void OnMessageBoxClick()
15+
{
16+
UiMessageBox.ShowMessageBox("This is a message <b>box</b>", _ =>
17+
{
18+
_logger.Info("MessageBox done");
19+
});
20+
}
21+
22+
public void OnMessageQuestionBoxClick()
23+
{
24+
UiMessageBox.ShowQuestionBox("This is a message question <b>box</b>", UiMessageBox.QuestionType.OkCancel, r =>
25+
{
26+
_logger.InfoFormat("MessageQuestionBox done with {0}", r);
27+
});
28+
}
29+
30+
public void OnMessageQuestionBoxCoroutineClick()
31+
{
32+
StartCoroutine(ShowMessageQuestionBoxCoroutine());
33+
}
34+
35+
private IEnumerator ShowMessageQuestionBoxCoroutine()
36+
{
37+
while (true)
38+
{
39+
var handle = UiMessageBox.ShowQuestionBox("Do you want to continue?", UiMessageBox.QuestionType.ContinueStop);
40+
yield return StartCoroutine(handle.WaitForHide());
41+
_logger.Info(handle.ReturnValue);
42+
if ((UiMessageBox.QuestionResult)handle.ReturnValue == UiMessageBox.QuestionResult.Continue)
43+
{
44+
var handle2 = UiMessageBox.ShowMessageBox("Let's do it again");
45+
yield return StartCoroutine(handle2.WaitForHide());
46+
}
47+
else
48+
{
49+
UiMessageBox.ShowMessageBox("Done");
50+
yield break;
51+
}
52+
}
53+
}
54+
55+
public void OnTestDialogBoxClick()
56+
{
57+
var handle = UiManager.Instance.ShowModalRoot<TestDialogBox>("Input your name?");
58+
handle.Hidden += (dlg, val) =>
59+
{
60+
if (val != null)
61+
UiMessageBox.ShowMessageBox("Name: " + val);
62+
else
63+
UiMessageBox.ShowMessageBox("Canceled");
64+
};
65+
}
66+
}

src/UnityPackage/Assets/Middleware/UiManagerSample/UiManagerSample.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)