IEnumerator Init() { yield return(new WaitForSeconds(0.1f)); GameObject display = new GameObject("GMPDisplay"); GameObject textObj = new GameObject("GMPDisplayText"); if (Config.uiOnTop) { textObj.transform.position = new Vector3(0.1f, 3f, 7f); textObj.transform.localScale *= 1.5f; } else { textObj.transform.position = new Vector3(0.2f, -1f, 7f); textObj.transform.localScale *= 2.0f; } textObj.transform.SetParent(display.transform); var counterImage = Resources.FindObjectsOfTypeAll <ScoreMultiplierUIController>().First(). GetField <Image, ScoreMultiplierUIController>("_multiplierProgressImage"); GameObject canvasobj = new GameObject("GMPDisplayCanvas"); Canvas canvas = canvasobj.AddComponent <Canvas>(); canvas.renderMode = RenderMode.WorldSpace; CanvasScaler cs = canvasobj.AddComponent <CanvasScaler>(); cs.scaleFactor = 10.0f; cs.dynamicPixelsPerUnit = 10f; GraphicRaycaster gr = canvasobj.AddComponent <GraphicRaycaster>(); canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f); canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f); GameObject counter = new GameObject("GMPDisplayCounter"); chargeCounter = counter.AddComponent <ImageView>(); counter.transform.parent = canvasobj.transform; counter.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0.5f); counter.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0.5f); counter.transform.localScale = new Vector3(1f, 1f, 1f); chargeCounter.sprite = counterImage.sprite; chargeCounter.type = Image.Type.Filled; chargeCounter.fillMethod = Image.FillMethod.Radial360; chargeCounter.fillOrigin = (int)Image.Origin360.Top; chargeCounter.fillClockwise = true; chargeCounter.fillAmount = GameModifiersController.charges / Config.maxCharges; chargeCounter.color = Color.green; GameObject background = new GameObject("GMPDisplayBackGround"); var bg = background.AddComponent <ImageView>(); background.transform.parent = canvasobj.transform; background.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0.5f); background.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0.5f); background.transform.localScale = new Vector3(1f, 1f, 1f); bg.sprite = counterImage.sprite; bg.CrossFadeAlpha(0.05f, 1f, false); canvasobj.GetComponent <RectTransform>().SetParent(textObj.transform, false); canvasobj.transform.localPosition = new Vector3(-0.1f, -.1f, 0f); chargeText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, "Charges", new Vector2(-0.25f, 0.5f)) as CurvedTextMeshPro; chargeText.fontSize = 3; chargeText.transform.localScale *= .08f; chargeText.color = Color.white; // chargeText.font = Resources.Load<TMP_FontAsset>("Teko-Medium SDF No Glow"); chargeText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f); chargeText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f); chargeText.GetComponent <RectTransform>().SetParent(canvas.transform, false); chargeCountText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, GameModifiersController.charges.ToString(), new Vector2(0, 0)) as CurvedTextMeshPro; chargeCountText.text = GameModifiersController.charges.ToString(); chargeCountText.alignment = TextAlignmentOptions.Center; chargeCountText.transform.localScale *= .08f; chargeCountText.fontSize = 2.5f; chargeCountText.color = Color.white; chargeCountText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f); chargeCountText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f); chargeCountText.GetComponent <RectTransform>().SetParent(canvas.transform, false); // chargeCountText.transform.localPosition = new Vector3(-0.0925f, -.13f, 0f); cooldownText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, GameModifiersController.charges.ToString(), new Vector2(-1f, 0.015f)) as CurvedTextMeshPro; cooldownText.text = ""; cooldownText.alignment = TextAlignmentOptions.MidlineRight; cooldownText.fontSize = 2.5f; cooldownText.transform.localScale *= .08f; cooldownText.color = Color.red; // cooldownText.font = Resources.Load<TMP_FontAsset>("Teko-Medium SDF No Glow"); cooldownText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 10f); cooldownText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f); cooldownText.GetComponent <RectTransform>().SetParent(canvas.transform, false); activeCommandText = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, GameModifiersController.charges.ToString(), new Vector2(1f, 0.015f)) as CurvedTextMeshPro; activeCommandText.text = ""; activeCommandText.alignment = TextAlignmentOptions.MidlineLeft; activeCommandText.fontSize = 2.5f; activeCommandText.transform.localScale *= .08f; activeCommandText.color = Color.yellow; // activeCommandText.font = Resources.Load<TMP_FontAsset>("Teko-Medium SDF No Glow"); activeCommandText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 10f); activeCommandText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f); activeCommandText.GetComponent <RectTransform>().SetParent(canvas.transform, false); GameObject coreGameHUD = Resources.FindObjectsOfTypeAll <CoreGameHUDController>()?.FirstOrDefault(x => x.isActiveAndEnabled)?.gameObject ?? null; FlyingGameHUDRotation flyingGameHUD = Resources.FindObjectsOfTypeAll <FlyingGameHUDRotation>().FirstOrDefault(x => x.isActiveAndEnabled); if (coreGameHUD != null) { display.transform.SetParent(coreGameHUD.transform, true); } // textObj.transform.position = new Vector3(0, 0f, 0); display.transform.localPosition = new Vector3(0, 0f, 0f); display.transform.localRotation = Quaternion.identity; if (flyingGameHUD != null) { display.transform.localPosition = new Vector3(0, 0.75f, 6f); display.transform.eulerAngles = new Vector3(345f, 0f, 0f); } var canvasSettings = canvasobj.AddComponent <CurvedCanvasSettings>(); canvasSettings.SetRadius(0); display.SetActive(GMPUI.chatIntegration); initialized = true; }
static void Postfix(MissionHelpSO missionHelp, MissionHelpViewController __instance) { if (missionHelp is CustomMissionHelpSO) { ChallengeInfo challengeInfo = (missionHelp as CustomMissionHelpSO).challengeInfo; string imagePath = (missionHelp as CustomMissionHelpSO).imagePath; Transform content = __instance.transform.GetChild(0); CurvedTextMeshPro title = content.GetChild(0).GetChild(1).GetComponent <CurvedTextMeshPro>(); Transform seperatorPrefab = content.GetChild(6).GetChild(1); Transform segmentPrefab = content.GetChild(1).GetChild(1); GameObject.Destroy(title.GetComponent <LocalizedTextMeshProUGUI>()); title.text = challengeInfo.title; title.richText = true; Transform infoContainer = GameObject.Instantiate(content.GetChild(1), content); infoContainer.SetSiblingIndex(content.childCount - 2); infoContainer.gameObject.SetActive(true); if (lastInfo != null) { GameObject.Destroy(lastInfo.gameObject); } lastInfo = infoContainer; foreach (Transform child in infoContainer) { GameObject.Destroy(child.gameObject); } foreach (ChallengeInfo.InfoSegment infoSegment in challengeInfo.segments) { Transform segment = GameObject.Instantiate(segmentPrefab, infoContainer); GameObject.Destroy(segment.GetComponentInChildren <LocalizedTextMeshProUGUI>()); if (infoSegment.text == "") { GameObject.Destroy(segment.GetComponentInChildren <CurvedTextMeshPro>().gameObject); } else { segment.GetComponentInChildren <CurvedTextMeshPro>().text = infoSegment.text; } ImageView imageView = segment.GetComponentInChildren <ImageView>(); if (infoSegment.imageName == "") { GameObject.Destroy(imageView.gameObject); } else { imageView.sprite = null; if (imageLoader == null) { imageLoader = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First(); } imageLoader.StartCoroutine(LoadSprite("file:///" + imagePath + infoSegment.imageName, imageView)); } if (infoSegment.hasSeperator) { GameObject.Instantiate(seperatorPrefab, infoContainer); } } } else { __instance.transform.GetChild(0).GetComponentInChildren <CurvedTextMeshPro>().text = "NEW OBJECTIVE"; } }