public void TestScaledValue() { ScaledValue scaledValue = new ScaledValue(0); Assert.AreEqual(0, scaledValue.Value); Assert.AreEqual((short)0, scaledValue.ShortValue); scaledValue = new ScaledValue(32767); Assert.AreEqual(32767, scaledValue.Value); Assert.AreEqual((short)32767, scaledValue.ShortValue); scaledValue = new ScaledValue(32768); Assert.AreEqual(32767, scaledValue.Value); Assert.AreEqual((short)32767, scaledValue.ShortValue); scaledValue = new ScaledValue(-32768); Assert.AreEqual(-32768, scaledValue.Value); Assert.AreEqual((short)-32768, scaledValue.ShortValue); scaledValue = new ScaledValue(-32769); Assert.AreEqual(-32768, scaledValue.Value); Assert.AreEqual((short)-32768, scaledValue.ShortValue); }
public static void CreateUnityGUIQuestLogWindow() { // Create GUI root: GameObject questLogWindowObject = AddChildGameObject("Quest Log Window", typeof(UnityGUIQuestLogWindow)); Selection.activeGameObject = questLogWindowObject; GameObject root = AddChildGameObject("GUI Root", typeof(GUIRoot)); Selection.activeGameObject = root; GameObject window = AddChildGameObject("Window", typeof(GUIWindow)); GameObject abandonQuestPopup = AddChildGameObject("Abandon Quest Popup", typeof(GUIWindow)); // Create quest window: Selection.activeObject = window; GameObject scrollView = AddChildGameObject("Scroll View", typeof(GUIScrollView)); Selection.activeGameObject = window; ScaledRect activeButtonRect = new ScaledRect(ScaledRectAlignment.TopCenter, ScaledRectAlignment.TopRight, ScaledValue.FromPixelValue(0), ScaledValue.FromPixelValue(0), ScaledValue.FromNormalizedValue(0.5f), ScaledValue.FromNormalizedValue(0.1f), 0, 0); GUIButton activeButton = CreateButton(activeButtonRect, "Active Quests", "ClickShowActiveQuests", questLogWindowObject); ScaledRect completedButtonRect = new ScaledRect(ScaledRectAlignment.TopCenter, ScaledRectAlignment.TopLeft, ScaledValue.FromPixelValue(0), ScaledValue.FromPixelValue(0), ScaledValue.FromNormalizedValue(0.5f), ScaledValue.FromNormalizedValue(0.1f), 0, 0); GUIButton completedButton = CreateButton(completedButtonRect, "Completed Quests", "ClickShowCompletedQuests", questLogWindowObject); ScaledRect closeRect = new ScaledRect(ScaledRectAlignment.BottomCenter, ScaledRectAlignment.BottomCenter, ScaledValue.FromPixelValue(0), ScaledValue.FromPixelValue(0), ScaledValue.FromNormalizedValue(1), ScaledValue.FromNormalizedValue(0.1f), 0, 0); CreateButton(closeRect, "Close", "OnClose", questLogWindowObject); UnityGUIQuestLogWindow questLogWindow = questLogWindowObject.GetComponent <UnityGUIQuestLogWindow>(); questLogWindow.guiRoot = root.GetComponent <GUIRoot>(); questLogWindow.scrollView = scrollView.GetComponent <GUIScrollView>(); questLogWindow.activeButton = activeButton; questLogWindow.completedButton = completedButton; // Create abandon quest popup: Selection.activeObject = abandonQuestPopup; ScaledRect okButtonRect = new ScaledRect(ScaledRectAlignment.BottomCenter, ScaledRectAlignment.BottomRight, ScaledValue.FromPixelValue(0), ScaledValue.FromPixelValue(0), ScaledValue.FromNormalizedValue(0.5f), ScaledValue.FromNormalizedValue(0.1f), 0, 0); GUIButton okButton = CreateButton(okButtonRect, "Abandon", "ClickConfirmAbandonQuest", questLogWindowObject); ScaledRect cancelButtonRect = new ScaledRect(ScaledRectAlignment.BottomCenter, ScaledRectAlignment.BottomLeft, ScaledValue.FromPixelValue(0), ScaledValue.FromPixelValue(0), ScaledValue.FromNormalizedValue(0.5f), ScaledValue.FromNormalizedValue(0.1f), 0, 0); GUIButton cancelButton = CreateButton(cancelButtonRect, "Cancel", "ClickCancelAbandonQuest", questLogWindowObject); GameObject questTitle = AddChildGameObject("Quest Title Label", typeof(GUILabel)); questLogWindow.abandonQuestPopup.panel = abandonQuestPopup.GetComponent <GUIWindow>(); questLogWindow.abandonQuestPopup.ok = okButton; questLogWindow.abandonQuestPopup.cancel = cancelButton; questLogWindow.abandonQuestPopup.questTitleLabel = questTitle.GetComponent <GUILabel>(); // Select main window: Selection.activeGameObject = questLogWindowObject; }