public static void Initialize(GameObject modMenuObject) { if (BTModMenuManager.modMenuObject == modMenuObject) { return; } BTModMenuManager.modMenuObject = modMenuObject; GameObject togglesContainer = BTUIUtils.FindGameObjectAtPath(modMenuObject, "TogglesContainer"); if (togglesContainer == null) { return; } GameObject toggleFogButton = BTUIUtils.FindGameObjectAtPath(togglesContainer, "ToggleFogContainer/ToggleFogButton"); GameObject toggleSkyboxButton = BTUIUtils.FindGameObjectAtPath(togglesContainer, "ToggleSkyboxContainer/ToggleSkyboxButton"); GameObject disableWaterButton = BTUIUtils.FindGameObjectAtPath(togglesContainer, "DisableWaterContainer/DisableWaterButton"); GameObject toggleOrthographicButton = BTUIUtils.FindGameObjectAtPath(togglesContainer, "ToggleOrthographicContainer/ToggleOrthographicButton"); if (toggleFogButton != null) { toggleFogButton.GetComponent <Button>().onClick.AddListener(ToggleFogClicked); GameObject text = BTUIUtils.FindGameObjectAtPath(toggleFogButton, "Text"); if (text != null) { toggleFogButtonText = text.GetComponent <Text>(); } } if (toggleSkyboxButton != null) { toggleSkyboxButton.GetComponent <Button>().onClick.AddListener(ToggleSkyboxClicked); GameObject text = BTUIUtils.FindGameObjectAtPath(toggleSkyboxButton, "Text"); if (text != null) { toggleSkyboxButtonText = text.GetComponent <Text>(); } } if (disableWaterButton != null) { disableWaterButton.GetComponent <Button>().onClick.AddListener(DisableWaterClicked); } if (toggleOrthographicButton != null) { toggleOrthographicButton.GetComponent <Button>().onClick.AddListener(ToggleOrthographicClicked); GameObject text = BTUIUtils.FindGameObjectAtPath(toggleOrthographicButton, "Text"); if (text != null) { toggleOrthographicButtonText = text.GetComponent <Text>(); } } }
public static void Initialize(GameObject infoHUDObject) { if (BTInfoHUDManager.infoHUDObject == infoHUDObject) { return; } BTInfoHUDManager.infoHUDObject = infoHUDObject; GameObject statusContainerObject = BTUIUtils.FindGameObjectAtPath(infoHUDObject, "StatusContainer"); if (statusContainerObject == null) { return; } GameObject fogStatusTextObject = BTUIUtils.FindGameObjectAtPath(statusContainerObject, "FogStatusContainer/FogStatusText"); GameObject skyboxStatusTextObject = BTUIUtils.FindGameObjectAtPath(statusContainerObject, "SkyboxStatusContainer/SkyboxStatusText"); GameObject orthographicStatusTextObject = BTUIUtils.FindGameObjectAtPath(statusContainerObject, "OrthographicStatusContainer/OrthographicStatusText"); GameObject fovStatusTextObject = BTUIUtils.FindGameObjectAtPath(statusContainerObject, "FOVStatusContainer/FOVStatusText"); GameObject orthographicSizeStatusTextObject = BTUIUtils.FindGameObjectAtPath(statusContainerObject, "OrthographicSizeStatusContainer/OrthographicSizeStatusText"); if (fogStatusTextObject != null) { fogInfoText = fogStatusTextObject.GetComponent <Text>(); } if (skyboxStatusTextObject != null) { skyboxInfoText = skyboxStatusTextObject.GetComponent <Text>(); } if (orthographicStatusTextObject != null) { orthographicInfoText = orthographicStatusTextObject.GetComponent <Text>(); } if (fovStatusTextObject != null) { fovInfoText = fovStatusTextObject.GetComponent <Text>(); } if (orthographicSizeStatusTextObject != null) { orthographicSizeInfoText = orthographicSizeStatusTextObject.GetComponent <Text>(); } }
public static void Initialize(GameObject cutscenePlayerObject) { if (BTCutsceneManager.cutscenePlayerObject == cutscenePlayerObject) { configHolder.LogMessage(LogType.Error, "BTCutsceneManager got initialized with null cutscenePlayerWindow!"); return; } BTCutsceneManager.cutscenePlayerObject = cutscenePlayerObject; GameObject closeButtonObject = BTUIUtils.FindGameObjectAtPath(cutscenePlayerObject, "Title/CloseButton"); if (closeButtonObject != null) { closeButtonObject.GetComponent <Button>().onClick.AddListener(OnCloseButtonClicked); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent Title/CloseButton from bundle"); } GameObject contentContainerObject = BTUIUtils.FindGameObjectAtPath(cutscenePlayerObject, "ContentContainer"); if (contentContainerObject == null) { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent ContentContainer from bundle"); } GameObject unlockCameraMovementObject = BTUIUtils.FindGameObjectAtPath(contentContainerObject, "FreeCameraTickboxContainer/Toggle"); if (unlockCameraMovementObject != null) { unloockCameraMovementToggle = unlockCameraMovementObject.GetComponent <Toggle>(); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent FreeCameraTickboxContainer/Toggle from bundle"); } GameObject cutsceneDropdownObject = BTUIUtils.FindGameObjectAtPath(contentContainerObject, "CutsceneSelectorContainer/Dropdown"); if (cutsceneDropdownObject != null) { cutsceneDropdown = cutsceneDropdownObject.GetComponent <Dropdown>(); cutsceneDropdown.onValueChanged.AddListener(OnCutsceneSelectionChanged); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent CutsceneSelectorContainer/Dropdown from bundle"); } GameObject timestampInputfieldObject = BTUIUtils.FindGameObjectAtPath(contentContainerObject, "TimestampInputContainer/InputField"); if (timestampInputfieldObject != null) { timestampInputField = timestampInputfieldObject.GetComponent <InputField>(); timestampInputField.onEndEdit.AddListener(OnTimestampInputChanged); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent TimestampInputContainer/InputField from bundle"); } GameObject currentSpeedInputfieldObject = BTUIUtils.FindGameObjectAtPath(contentContainerObject, "CurrentSpeedInputContainer/InputField"); if (currentSpeedInputfieldObject != null) { speedInputField = currentSpeedInputfieldObject.GetComponent <InputField>(); speedInputField.onEndEdit.AddListener(OnSpeedInputChanged); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent CurrentSpeedInputContainer/InputField from bundle"); } GameObject cutsceneControllerContainerObject = BTUIUtils.FindGameObjectAtPath(contentContainerObject, "CutsceneControllerContainer"); if (cutsceneControllerContainerObject == null) { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent CutsceneControllerContainer from bundle"); } GameObject playPauseButtonObject = BTUIUtils.FindGameObjectAtPath(cutsceneControllerContainerObject, "PlayPauseButton"); playPauseButtonPlayIcon = BTUIUtils.FindGameObjectAtPath(playPauseButtonObject, "PlayImage"); playPauseButtonPauseIcon = BTUIUtils.FindGameObjectAtPath(playPauseButtonObject, "PauseImage"); if (playPauseButtonObject != null) { playPauseButtonObject.GetComponent <Button>().onClick.AddListener(OnPlayPauseButtonClicked); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent PlayPauseButton from bundle"); } GameObject previousFrameButtonObject = BTUIUtils.FindGameObjectAtPath(cutsceneControllerContainerObject, "PreviousFrameButton"); if (previousFrameButtonObject != null) { previousFrameButtonObject.GetComponent <Button>().onClick.AddListener(OnPreviousFrameButtonClicked); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent PreviousFrameButton from bundle"); } GameObject nextFrameButtonObject = BTUIUtils.FindGameObjectAtPath(cutsceneControllerContainerObject, "NextFrameButton"); if (nextFrameButtonObject != null) { nextFrameButtonObject.GetComponent <Button>().onClick.AddListener(OnNextFrameButtonClicked); } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent NextFrameButton from bundle"); } GameObject frameSliderObject = BTUIUtils.FindGameObjectAtPath(cutsceneControllerContainerObject, "Slider"); if (frameSliderObject != null) { frameSlider = frameSliderObject.GetComponent <Slider>(); frameSlider.onValueChanged.AddListener(OnFrameSliderValueChanged); frameSlider.minValue = 0f; frameSlider.maxValue = 1f; } else { configHolder.LogMessage(LogType.Error, "BTCutsceneManager could not initialize UIComponent Slider from bundle"); } }
private static void PrepareUI() { if (canvasObject != null) { return; } AssetBundle uiBundle = null; try{ string bundlePath = (BTConfigHolder.basePath + "btuiBundle").Replace('/', Path.DirectorySeparatorChar); uiBundle = AssetBundle.LoadFromFile(bundlePath); if (uiBundle == null) { configHolder.LogMessage(LogType.Error, "failed to load bundleFile at path: " + bundlePath); return; } canvasObject = uiBundle.LoadAsset <GameObject>("Canvas"); if (canvasObject == null) { configHolder.LogMessage(LogType.Error, "failed to load CanvasObject from bundle"); return; } canvasObject = UnityEngine.Object.Instantiate <GameObject>(canvasObject); if (canvasObject == null) { configHolder.LogMessage(LogType.Error, "failed to instantiate CanvasObject"); return; } UnityEngine.Object.DontDestroyOnLoad(canvasObject); canvasComponent = canvasObject.GetComponent <Canvas>(); if (canvasComponent == null) { configHolder.LogMessage(LogType.Error, "failed to obtain Canvas component!"); return; } initialCanvasScale = canvasComponent.scaleFactor; modMenuObject = BTUIUtils.PrepareWindow(canvasObject, "ModMenuWindow"); if (modMenuObject == null) { configHolder.LogMessage(LogType.Error, "failed to load modMenuWindow from bundle"); return; } BTModMenuManager.Initialize(modMenuObject); animPlayerObject = BTUIUtils.PrepareWindow(canvasObject, "AnimPlayerWindow"); if (animPlayerObject == null) { configHolder.LogMessage(LogType.Error, "failed to load animPlayerWindow from bundle"); return; } BTAnimationPlayerManager.Initialize(animPlayerObject); infoHUDObject = BTUIUtils.PrepareWindow(canvasObject, "InfoHUD"); if (infoHUDObject == null) { configHolder.LogMessage(LogType.Error, "failed to load infoHudWindow from bundle"); return; } BTInfoHUDManager.Initialize(infoHUDObject); cutscenePlayerObject = BTUIUtils.PrepareWindow(canvasObject, "CutscenePlayerWindow"); if (cutscenePlayerObject == null) { configHolder.LogMessage(LogType.Error, "failed to load cutscenePlayerWindow from bundle"); return; } BTCutsceneManager.Initialize(cutscenePlayerObject); }catch (Exception e) { configHolder.LogMessage(LogType.Error, "caught exception while loading UI: " + e.ToString()); }finally{ if (uiBundle != null) { uiBundle.Unload(false); } } }
public static void Initialize(GameObject animationPlayerObject) { if (BTAnimationPlayerManager.animationPlayerObject == animationPlayerObject) { return; } BTAnimationPlayerManager.animationPlayerObject = animationPlayerObject; GameObject animationLoadButton = BTUIUtils.FindGameObjectAtPath(animationPlayerObject, "LoadAnimsButtonContainer/LoadAnimsButton"); if (animationLoadButton != null) { animationLoadButton.GetComponent <Button>().onClick.AddListener(FindAnimationsClicked); } GameObject animDropdownObject = BTUIUtils.FindGameObjectAtPath(animationPlayerObject, "AnimSelectorContainer/Dropdown"); if (animDropdownObject != null) { animationDropdown = animDropdownObject.GetComponent <Dropdown>(); animationDropdown.onValueChanged.AddListener(OnSelectedAnimationChanged); } GameObject frameInputFieldObject = BTUIUtils.FindGameObjectAtPath(animationPlayerObject, "AnimPlayer/FrameSelector/InputField"); if (frameInputFieldObject != null) { frameInputField = frameInputFieldObject.GetComponent <InputField>(); frameInputField.onEndEdit.AddListener(OnSelectedFrameChanged); } GameObject speedInputFieldObject = BTUIUtils.FindGameObjectAtPath(animationPlayerObject, "AnimPlayer/SpeedSelector/InputField"); if (speedInputFieldObject != null) { speedInputField = speedInputFieldObject.GetComponent <InputField>(); speedInputField.onEndEdit.AddListener(OnSelectedSpeedChanged); } GameObject frameStepper = BTUIUtils.FindGameObjectAtPath(animationPlayerObject, "AnimPlayer/FrameStepper"); GameObject playPauseButtonObject = BTUIUtils.FindGameObjectAtPath(frameStepper, "PlayPauseButton"); playPauseButtonPlayIcon = BTUIUtils.FindGameObjectAtPath(playPauseButtonObject, "PlayImage"); playPauseButtonPauseIcon = BTUIUtils.FindGameObjectAtPath(playPauseButtonObject, "PauseImage"); if (playPauseButtonObject != null) { playPauseButtonObject.GetComponent <Button>().onClick.AddListener(PlayPauseAnimation); } GameObject previousFrameButtonObject = BTUIUtils.FindGameObjectAtPath(frameStepper, "PreviousFrameButton"); if (previousFrameButtonObject != null) { previousFrameButtonObject.GetComponent <Button>().onClick.AddListener(OnPreviousFrameButtonClicked); } GameObject sliderObject = BTUIUtils.FindGameObjectAtPath(frameStepper, "Slider"); if (sliderObject != null) { frameSlider = sliderObject.GetComponent <Slider>(); frameSlider.onValueChanged.AddListener(OnFrameSliderDragged); frameSlider.minValue = 0f; frameSlider.maxValue = 1f; } GameObject nextFrameButtonObject = BTUIUtils.FindGameObjectAtPath(frameStepper, "NextFrameButton"); if (nextFrameButtonObject != null) { nextFrameButtonObject.GetComponent <Button>().onClick.AddListener(OnNextFrameButtonClicked); } }