com.valectric.mooserunner 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/CLI~/mooserunnerCli.exe +0 -0
- package/CLI~/mooserunnerCliDaemon.exe +0 -0
- package/Editor/GUI/MooseRunnerFail.png +0 -0
- package/Editor/GUI/MooseRunnerFail.png.meta +140 -0
- package/Editor/GUI/MooseRunnerGreenLED.png +0 -0
- package/Editor/GUI/MooseRunnerGreenLED.png.meta +140 -0
- package/Editor/GUI/MooseRunnerLogoBannerSmall.png +0 -0
- package/Editor/GUI/MooseRunnerLogoBannerSmall.png.meta +140 -0
- package/Editor/GUI/MooseRunnerNotRun.png +0 -0
- package/Editor/GUI/MooseRunnerNotRun.png.meta +140 -0
- package/Editor/GUI/MooseRunnerPass.png +0 -0
- package/Editor/GUI/MooseRunnerPass.png.meta +140 -0
- package/Editor/GUI/MooseRunnerYellowLED.png +0 -0
- package/Editor/GUI/MooseRunnerYellowLED.png.meta +140 -0
- package/Editor/MooseRunner.Editor.asmdef +17 -0
- package/Editor/MooseRunner.Editor.asmdef.meta +7 -0
- package/Editor/MooseRunner.Internal.Editor.dll +0 -0
- package/Editor/MooseRunner.Internal.Editor.dll.meta +33 -0
- package/Editor/MooseRunner.SessionRecorder.dll +0 -0
- package/Editor/MooseRunner.SessionRecorder.dll.meta +33 -0
- package/Editor/MooseRunner.Worker.dll +0 -0
- package/Editor/MooseRunner.Worker.dll.meta +33 -0
- package/Editor/_WrapperStub.cs +3 -0
- package/Editor/_WrapperStub.cs.meta +11 -0
- package/LICENSE.md +28 -0
- package/README.md +347 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/DoNotDestroyOnTeardown.cs +262 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/DoNotDestroyOnTeardown.cs.meta +2 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/MooseRunner.helper.asmdef +18 -0
- package/Runtime/Helpers/DoNotDestroyOnTeardown/MooseRunner.helper.asmdef.meta +7 -0
- package/Runtime/MooseRunner.Helpers.Runtime.dll +0 -0
- package/Runtime/MooseRunner.Helpers.Runtime.dll.meta +27 -0
- package/Runtime/MooseRunner.Internal.dll +0 -0
- package/Runtime/MooseRunner.Internal.dll.meta +27 -0
- package/Runtime/MooseRunner.Multiplaytest.Types.dll +0 -0
- package/Runtime/MooseRunner.Multiplaytest.Types.dll.meta +27 -0
- package/Runtime/MooseRunner.Runtime.asmdef +20 -0
- package/Runtime/MooseRunner.Runtime.asmdef.meta +7 -0
- package/Runtime/MooseRunner.SessionRecorder.Runtime.dll +0 -0
- package/Runtime/MooseRunner.SessionRecorder.Runtime.dll.meta +27 -0
- package/Runtime/MooseRunner.dll +0 -0
- package/Runtime/MooseRunner.dll.meta +27 -0
- package/Runtime/_WrapperStub.cs +3 -0
- package/Runtime/_WrapperStub.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/BatchCancellationTests.cs +37 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/BatchCancellationTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/CancellationTokenTests.cs +186 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/CancellationTokenTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/MooseRunner.Demo.CancellationTokens.Tests.asmdef +28 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/MooseRunner.Demo.CancellationTokens.Tests.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/SetupTeardownCancellationTests.cs +84 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/SetupTeardownCancellationTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/TESTING_INSTRUCTIONS.md +491 -0
- package/Samples~/Demos/MooseRunner.Demo.CancellationTokens.Tests/TESTING_INSTRUCTIONS.md.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/ErrorHandelingTest.cs +177 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/ErrorHandelingTest.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/MooseRunner.Demo.ErrorHandling.Tests.asmdef +28 -0
- package/Samples~/Demos/MooseRunner.Demo.ErrorHandling.Tests/MooseRunner.Demo.ErrorHandling.Tests.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogEntry.cs +51 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogEntry.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogFileParser.cs +70 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/LogFileParser.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunner.Demo.Flow.TestSupport.asmdef +22 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunner.Demo.Flow.TestSupport.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference.json +62 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference.json.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_2.json +33 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_2.json.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_No_UniTask.json +57 -0
- package/Samples~/Demos/MooseRunner.Demo.Flow.TestSupport/MooseRunnerLogReference_No_UniTask.json.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MethodOrderAttributeTests.cs +62 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MethodOrderAttributeTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MooseRunner.Demo.OrderAttribute.asmdef +20 -0
- package/Samples~/Demos/MooseRunner.Demo.OrderAttribute/MooseRunner.Demo.OrderAttribute.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/CatAnimation.controller +276 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/CatAnimation.controller.meta +8 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Enemy.cs +101 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Enemy.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/FireComponent.cs +19 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/FireComponent.cs.meta +3 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model/Ghost_cat.fbx +0 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model/Ghost_cat.fbx.meta +547 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Model.meta +8 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/MooseRunner.Demo.RealUseCase.asmdef +29 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/MooseRunner.Demo.RealUseCase.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseScene.unity +4758 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseScene.unity.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseTest.cs +307 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/RealUseCaseTest.cs.meta +3 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources/Ghost_cat.prefab +157 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources/Ghost_cat.prefab.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.RealUseCase/Resources.meta +8 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MessageDisplayManager.cs +291 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MessageDisplayManager.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunner.Demo.Support.asmdef +19 -0
- package/Samples~/Demos/MooseRunner.Demo.Support/MooseRunner.Demo.Support.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestBase1.cs +71 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestBase1.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass1.cs +301 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass1.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass2.cs +69 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/DummyTestClass2.cs.meta +11 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/ExplicitAttributeTests.cs +36 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/ExplicitAttributeTests.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/HumanReviewModeDemo.cs +99 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/HumanReviewModeDemo.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/InstanceHandlingVerificationTest.cs +99 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/InstanceHandlingVerificationTest.cs.meta +2 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/MooseRunner.Demo.Tests.asmdef +23 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/MooseRunner.Demo.Tests.asmdef.meta +7 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/PauseTestExecutionDemo.cs +74 -0
- package/Samples~/Demos/MooseRunner.Demo.Tests/PauseTestExecutionDemo.cs.meta +2 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.mat +137 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.mat.meta +8 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.png +0 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Background.png.meta +127 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.mat +71 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.mat.meta +8 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.png +0 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.png.meta +127 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.shadergraph +1910 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/Grid.shadergraph.meta +10 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/GridNormal.png +0 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials/GridNormal.png.meta +127 -0
- package/Samples~/Demos/TestResources/OneCamera/Materials.meta +8 -0
- package/Samples~/Demos/TestResources/OneCamera/OneCameraScene.unity +598 -0
- package/Samples~/Demos/TestResources/OneCamera/OneCameraScene.unity.meta +7 -0
- package/Samples~/Demos/TestResources/OneCamera.meta +8 -0
- package/Third Party Notices.md +37 -0
- package/package.json +38 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.UI;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Diagnostics;
|
|
5
|
+
using System.Reflection;
|
|
6
|
+
using static UnityEngine.EventSystems.EventTrigger;
|
|
7
|
+
using Debug = System.Diagnostics.Debug;
|
|
8
|
+
|
|
9
|
+
namespace MooseRunner.Internal.Tests
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Manages the display of messages in a persistent UI canvas.
|
|
13
|
+
/// Messages are displayed in a vertical list and are automatically removed after their lifetime expires.
|
|
14
|
+
/// </summary>
|
|
15
|
+
public class MessageDisplayManager : MonoBehaviour
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// The singleton instance of the <see cref="MessageDisplayManager"/>.
|
|
19
|
+
/// </summary>
|
|
20
|
+
private static MessageDisplayManager _instance;
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Provides global access to the <see cref="MessageDisplayManager"/> instance.
|
|
24
|
+
/// Ensures that the manager is created and persists across scenes.
|
|
25
|
+
/// </summary>
|
|
26
|
+
public static MessageDisplayManager Instance
|
|
27
|
+
{
|
|
28
|
+
get
|
|
29
|
+
{
|
|
30
|
+
// If instance exists, return it
|
|
31
|
+
if (_instance != null) return _instance;
|
|
32
|
+
|
|
33
|
+
// 1. Find any existing instance in the scene
|
|
34
|
+
MessageDisplayManager[] instances = FindObjectsByType<MessageDisplayManager>(FindObjectsSortMode.None);
|
|
35
|
+
if (instances.Length > 0)
|
|
36
|
+
{
|
|
37
|
+
_instance = instances[0];
|
|
38
|
+
|
|
39
|
+
if (instances.Length > 1)
|
|
40
|
+
{
|
|
41
|
+
UnityEngine.Debug.LogWarning("Multiple TestRunnerHelper instances found! Using the first one.");
|
|
42
|
+
// Optionally, destroy duplicates here
|
|
43
|
+
for (int i = 1; i < instances.Length; i++)
|
|
44
|
+
{
|
|
45
|
+
Destroy(instances[i].gameObject);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return _instance;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 2. No instance found, instantiate the prefab
|
|
52
|
+
if (_instance == null)
|
|
53
|
+
{
|
|
54
|
+
GameObject obj = new GameObject("MessageDisplayManager");
|
|
55
|
+
_instance = obj.AddComponent<MessageDisplayManager>();
|
|
56
|
+
DontDestroyOnLoad(obj); // Ensure it persists across scenes
|
|
57
|
+
}
|
|
58
|
+
return _instance;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
/// The canvas used to display the message UI.
|
|
64
|
+
/// </summary>
|
|
65
|
+
private Canvas _canvas;
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// The content area within the canvas that holds all displayed messages.
|
|
69
|
+
/// </summary>
|
|
70
|
+
private RectTransform _contentArea;
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
/// A dictionary that stores active messages, indexed by a unique key derived from the caller's context.
|
|
74
|
+
/// </summary>
|
|
75
|
+
private readonly Dictionary<string, MessageEntry> _messages = new Dictionary<string, MessageEntry>();
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// The default duration (in seconds) for which a message remains visible.
|
|
79
|
+
/// </summary>
|
|
80
|
+
private const float MessageLifetime = 10f;
|
|
81
|
+
|
|
82
|
+
///<summary>
|
|
83
|
+
///Keeps track of last method
|
|
84
|
+
/// </summary>
|
|
85
|
+
private string _lastMethod;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/// <summary>
|
|
89
|
+
/// Represents a single message entry in the display manager.
|
|
90
|
+
/// </summary>
|
|
91
|
+
private class MessageEntry
|
|
92
|
+
{
|
|
93
|
+
/// <summary>
|
|
94
|
+
/// The text content of the message.
|
|
95
|
+
/// </summary>
|
|
96
|
+
public string DisplayText;
|
|
97
|
+
|
|
98
|
+
/// <summary>
|
|
99
|
+
/// The remaining lifetime of the message, in seconds.
|
|
100
|
+
/// </summary>
|
|
101
|
+
public float RemainingTime;
|
|
102
|
+
|
|
103
|
+
/// <summary>
|
|
104
|
+
/// The UI element used to display the message.
|
|
105
|
+
/// </summary>
|
|
106
|
+
public Text UIElement;
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
/// Initializes a new instance of the <see cref="MessageEntry"/> class.
|
|
110
|
+
/// </summary>
|
|
111
|
+
/// <param name="text">The message text to display.</param>
|
|
112
|
+
/// <param name="duration">The duration the message should remain visible.</param>
|
|
113
|
+
/// <param name="uiElement">The UI text element associated with the message.</param>
|
|
114
|
+
public MessageEntry(string text, float duration, Text uiElement)
|
|
115
|
+
{
|
|
116
|
+
DisplayText = text;
|
|
117
|
+
RemainingTime = duration;
|
|
118
|
+
UIElement = uiElement;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// <summary>
|
|
123
|
+
/// Ensures that the UI elements for displaying messages are created and properly configured.
|
|
124
|
+
/// </summary>
|
|
125
|
+
private void EnsureUIExists()
|
|
126
|
+
{
|
|
127
|
+
if (_canvas == null)
|
|
128
|
+
{
|
|
129
|
+
|
|
130
|
+
// Create Canvas
|
|
131
|
+
_canvas = gameObject.AddComponent<Canvas>();
|
|
132
|
+
_canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
|
133
|
+
DontDestroyOnLoad(gameObject);
|
|
134
|
+
|
|
135
|
+
// Add a Canvas Scaler
|
|
136
|
+
CanvasScaler scaler = gameObject.AddComponent<CanvasScaler>();
|
|
137
|
+
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
|
138
|
+
|
|
139
|
+
// Add a Scroll View for Messages
|
|
140
|
+
GameObject scrollViewObj = new GameObject("ScrollView");
|
|
141
|
+
scrollViewObj.transform.SetParent(gameObject.transform);
|
|
142
|
+
RectTransform scrollRectTransform = scrollViewObj.AddComponent<RectTransform>();
|
|
143
|
+
scrollRectTransform.anchorMin = new Vector2(0, 0);
|
|
144
|
+
scrollRectTransform.anchorMax = new Vector2(1, 1);
|
|
145
|
+
scrollRectTransform.sizeDelta = Vector2.zero;
|
|
146
|
+
scrollRectTransform.offsetMin = new Vector2(10, 10);
|
|
147
|
+
scrollRectTransform.offsetMax = new Vector2(-10, -10);
|
|
148
|
+
|
|
149
|
+
ScrollRect scrollRect = scrollViewObj.AddComponent<ScrollRect>();
|
|
150
|
+
scrollRect.horizontal = false;
|
|
151
|
+
|
|
152
|
+
// Create Content Area
|
|
153
|
+
GameObject contentObj = new GameObject("Content");
|
|
154
|
+
contentObj.transform.SetParent(scrollViewObj.transform);
|
|
155
|
+
_contentArea = contentObj.AddComponent<RectTransform>();
|
|
156
|
+
|
|
157
|
+
_contentArea.anchorMin = new Vector2(0, 1);
|
|
158
|
+
_contentArea.anchorMax = new Vector2(1, 1);
|
|
159
|
+
_contentArea.pivot = new Vector2(0.5f, 1);
|
|
160
|
+
_contentArea.sizeDelta = new Vector2(0, 0);
|
|
161
|
+
_contentArea.offsetMin = new Vector2(0, 0);
|
|
162
|
+
_contentArea.offsetMax = new Vector2(0, 0);
|
|
163
|
+
|
|
164
|
+
scrollRect.content = _contentArea;
|
|
165
|
+
|
|
166
|
+
VerticalLayoutGroup layoutGroup = contentObj.AddComponent<VerticalLayoutGroup>();
|
|
167
|
+
layoutGroup.childAlignment = TextAnchor.UpperCenter;
|
|
168
|
+
layoutGroup.childScaleWidth = true;
|
|
169
|
+
layoutGroup.childScaleHeight = true;
|
|
170
|
+
layoutGroup.childControlWidth = false;
|
|
171
|
+
layoutGroup.childControlHeight = false;
|
|
172
|
+
layoutGroup.childForceExpandWidth = false;
|
|
173
|
+
layoutGroup.childForceExpandHeight = false;
|
|
174
|
+
|
|
175
|
+
Mask mask = scrollViewObj.AddComponent<Mask>();
|
|
176
|
+
mask.showMaskGraphic = false;
|
|
177
|
+
scrollViewObj.AddComponent<Image>();
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/// <summary>
|
|
183
|
+
/// Displays a message in the UI with an optional duration.
|
|
184
|
+
/// </summary>
|
|
185
|
+
/// <param name="message">The message text to display.</param>
|
|
186
|
+
/// <param name="duration">The duration the message remains visible (in seconds).</param>
|
|
187
|
+
public void ShowMessage(string message, float duration = MessageLifetime)
|
|
188
|
+
{
|
|
189
|
+
EnsureUIExists();
|
|
190
|
+
|
|
191
|
+
// Get caller details using reflection
|
|
192
|
+
StackFrame frame = new StackFrame(1);
|
|
193
|
+
MethodBase method = frame.GetMethod();
|
|
194
|
+
string assemblyName = method.Module.Assembly.GetName().Name;
|
|
195
|
+
string methodKey = $"{assemblyName}.{method.ReflectedType.FullName}.{method.Name}";
|
|
196
|
+
if(_lastMethod != methodKey)
|
|
197
|
+
{
|
|
198
|
+
//Removes any method key which comes back so that they are in right order.
|
|
199
|
+
if (_messages.ContainsKey(methodKey)){
|
|
200
|
+
MessageEntry curr = _messages[methodKey];
|
|
201
|
+
Destroy(curr.UIElement.gameObject);
|
|
202
|
+
_messages.Remove(methodKey);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
_lastMethod = methodKey;
|
|
206
|
+
|
|
207
|
+
if (_messages.ContainsKey(methodKey))
|
|
208
|
+
{
|
|
209
|
+
_messages[methodKey].DisplayText = message;
|
|
210
|
+
_messages[methodKey].RemainingTime = duration;
|
|
211
|
+
}
|
|
212
|
+
else
|
|
213
|
+
{
|
|
214
|
+
GameObject messageObj = new GameObject("Message");
|
|
215
|
+
messageObj.transform.SetParent(_contentArea.transform);
|
|
216
|
+
|
|
217
|
+
Text messageText = messageObj.AddComponent<Text>();
|
|
218
|
+
messageText.fontStyle = FontStyle.Normal;
|
|
219
|
+
messageText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
|
|
220
|
+
messageText.fontSize = 70;
|
|
221
|
+
messageText.color = Color.black;
|
|
222
|
+
|
|
223
|
+
_messages[methodKey] = new MessageEntry(message, duration, messageText);
|
|
224
|
+
|
|
225
|
+
RectTransform rectTransform = messageText.GetComponent<RectTransform>();
|
|
226
|
+
rectTransform.anchorMin = new Vector2(0, 1);
|
|
227
|
+
rectTransform.anchorMax = new Vector2(1, 1);
|
|
228
|
+
rectTransform.pivot = new Vector2(0.5f, 1);
|
|
229
|
+
rectTransform.sizeDelta = new Vector2(3000, 100);
|
|
230
|
+
rectTransform.localScale = new Vector3(0.2f, 0.2f, 1);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
UpdateDisplayedMessages();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/// <summary>
|
|
237
|
+
/// Unity's Update method. Manages message lifetime and removes expired messages.
|
|
238
|
+
/// </summary>
|
|
239
|
+
private void Update()
|
|
240
|
+
{
|
|
241
|
+
if (_instance == null)
|
|
242
|
+
{
|
|
243
|
+
Transform content = gameObject.transform.GetChild(0).GetChild(0);
|
|
244
|
+
for (int i = content.childCount - 1; i >= 0; i--)
|
|
245
|
+
{
|
|
246
|
+
Destroy(content.GetChild(i).gameObject);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
List<string> keysToRemove = new List<string>();
|
|
251
|
+
bool displayDirty = false;
|
|
252
|
+
|
|
253
|
+
foreach (var entry in _messages)
|
|
254
|
+
{
|
|
255
|
+
entry.Value.RemainingTime -= Time.unscaledDeltaTime;
|
|
256
|
+
if (entry.Value.RemainingTime <= 0)
|
|
257
|
+
{
|
|
258
|
+
Destroy(entry.Value.UIElement.gameObject);
|
|
259
|
+
keysToRemove.Add(entry.Key);
|
|
260
|
+
displayDirty = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
foreach (var key in keysToRemove)
|
|
265
|
+
{
|
|
266
|
+
_messages.Remove(key);
|
|
267
|
+
displayDirty = true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (displayDirty)
|
|
271
|
+
{
|
|
272
|
+
UpdateDisplayedMessages();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/// <summary>
|
|
277
|
+
/// Updates the layout and content size of the displayed messages.
|
|
278
|
+
/// </summary>
|
|
279
|
+
private void UpdateDisplayedMessages()
|
|
280
|
+
{
|
|
281
|
+
float contentHeight = 0;
|
|
282
|
+
foreach (var entry in _messages.Values)
|
|
283
|
+
{
|
|
284
|
+
entry.UIElement.text = entry.DisplayText;
|
|
285
|
+
contentHeight += entry.UIElement.preferredHeight;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
_contentArea.sizeDelta = new Vector2(_contentArea.sizeDelta.x, contentHeight);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "MooseRunner.Demo.Support",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"UnityEngine.TestRunner"
|
|
6
|
+
],
|
|
7
|
+
"includePlatforms": [],
|
|
8
|
+
"excludePlatforms": [],
|
|
9
|
+
"allowUnsafeCode": false,
|
|
10
|
+
"precompiledReferences": [
|
|
11
|
+
"nunit.framework.dll"
|
|
12
|
+
],
|
|
13
|
+
"autoReferenced": false,
|
|
14
|
+
"defineConstraints": [
|
|
15
|
+
"UNITY_INCLUDE_TESTS"
|
|
16
|
+
],
|
|
17
|
+
"versionDefines": [],
|
|
18
|
+
"noEngineReferences": false
|
|
19
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using NUnit.Framework;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.SceneManagement;
|
|
6
|
+
using UnityEngine.TestTools;
|
|
7
|
+
using MooseRunner.Multiplaytest;
|
|
8
|
+
|
|
9
|
+
namespace MooseRunner.Internal.Tests
|
|
10
|
+
{
|
|
11
|
+
public class DummyTestBase1
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// Sets up the test environment before any test is executed.
|
|
15
|
+
/// Ensures that the "OneCameraScene" is created with a camera.
|
|
16
|
+
/// If the scene does not exist, it creates a new scene with a camera,
|
|
17
|
+
/// unloads all other scenes, and makes the new scene active.
|
|
18
|
+
/// </summary>
|
|
19
|
+
/// <returns>An enumerator for the asynchronous setup process.</returns>
|
|
20
|
+
|
|
21
|
+
[OneTimeSetUp]
|
|
22
|
+
public async Task SetUpOnce()
|
|
23
|
+
{
|
|
24
|
+
await MooseRunnerFacade.Instance.LoadSceneFromNameAsync("OneCameraScene");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Regular setup, called before each individual test
|
|
28
|
+
[SetUp]
|
|
29
|
+
public void SetUpBase()
|
|
30
|
+
{
|
|
31
|
+
Debug.Log("DummyTestBase1 SetUp: Called before each test.");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Dummy test that runs synchronously
|
|
35
|
+
[Test]
|
|
36
|
+
public void SyncTest()
|
|
37
|
+
{
|
|
38
|
+
Debug.Log("DummyTestBase1 SyncTest: This is a synchronous test.");
|
|
39
|
+
MessageDisplayManager.Instance.ShowMessage("DummyTestBase1 SyncTest");
|
|
40
|
+
Assert.IsTrue(true); // Dummy assertion
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Dummy test that runs asynchronously (PlayMode)
|
|
44
|
+
[UnityTest]
|
|
45
|
+
public IEnumerator CoroutineTestBaseClass()
|
|
46
|
+
{
|
|
47
|
+
Debug.Log("DummyTestBase1 CoroutineTestBaseClass: This is an coroutine test.");
|
|
48
|
+
for (int i = 0; i < 20; i++)
|
|
49
|
+
{
|
|
50
|
+
MessageDisplayManager.Instance.ShowMessage("DummyTestBase1 CoroutineTestBaseClass wait for " + (20 - i).ToString());
|
|
51
|
+
yield return new WaitForSeconds(1); // Simulate some asynchronous behavior
|
|
52
|
+
}
|
|
53
|
+
MessageDisplayManager.Instance.ShowMessage("DummyTestBase1 CoroutineTestBaseClass wait for 0");
|
|
54
|
+
Assert.IsTrue(true); // Dummy assertion
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Regular teardown, called after each individual test
|
|
58
|
+
[TearDown]
|
|
59
|
+
public void TearDownSetUpBase()
|
|
60
|
+
{
|
|
61
|
+
Debug.Log("DummyTestBase1 TearDown: Called after each test.");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// One-time teardown, called once after all tests in this class
|
|
65
|
+
[OneTimeTearDown]
|
|
66
|
+
public void OneTimeTearDownSetUpBase()
|
|
67
|
+
{
|
|
68
|
+
Debug.Log("DummyTestBase1 OneTimeTearDown: Called once after all tests.");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|