/// <summary> /// Set the global watermark to show that the player has hmd only custom notes. /// </summary> public static void CreateWatermark() { if (_watermarkObject != null) { return; } _watermarkObject = new GameObject("CustomNotes Watermark"); _watermarkObject.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); _watermarkObject.transform.position = new Vector3(0f, 0.025f, 0.8f); _watermarkObject.transform.rotation = Quaternion.Euler(90, 0, 0); Canvas watermarkCanvas = _watermarkObject.AddComponent <Canvas>(); watermarkCanvas.renderMode = RenderMode.WorldSpace; ((RectTransform)watermarkCanvas.transform).sizeDelta = new Vector2(100, 50); CurvedCanvasSettings canvasSettings = _watermarkObject.AddComponent <CurvedCanvasSettings>(); canvasSettings.SetRadius(0f); CurvedTextMeshPro text = (CurvedTextMeshPro)BeatSaberUI.CreateText((RectTransform)watermarkCanvas.transform, "Custom Notes Enabled", new Vector2(0, 0)); text.alignment = TextAlignmentOptions.Center; text.color = new Color(0.95f, 0.95f, 0.95f); SetLayer(_watermarkObject, NoteLayer.ThirdPerson); }
public Canvas CreateCanvasWithConfig(HUDCanvas canvasSettings) { GameObject canvasGameObject = new GameObject($"Counters+ | {canvasSettings.Name} Canvas"); canvasGameObject.layer = UILayer; Vector3 canvasPos = canvasSettings.Position; if (canvasSettings.MatchBaseGameHUDDepth) { canvasPos.Set(canvasPos.x, canvasPos.y, hudDepth); } Vector3 canvasRot = canvasSettings.Rotation; float canvasSize = canvasSettings.Size; Canvas canvas = canvasGameObject.AddComponent <Canvas>(); canvas.renderMode = RenderMode.WorldSpace; canvasGameObject.transform.localScale = Vector3.one / canvasSize; canvasGameObject.transform.position = canvasPos; canvasGameObject.transform.rotation = Quaternion.Euler(canvasRot); CurvedCanvasSettings curvedCanvasSettings = canvasGameObject.AddComponent <CurvedCanvasSettings>(); curvedCanvasSettings.SetRadius(canvasSettings.CurveRadius); // Inherit canvas properties from the Energy Bar to ignore the shockwave effect. // However, a caveat as that, when viewing through walls, UI elements will not appear. if (canvasSettings.IgnoreShockwaveEffect && energyCanvas != null) { canvas.overrideSorting = energyCanvas.overrideSorting; canvas.sortingLayerID = energyCanvas.sortingLayerID; canvas.sortingLayerName = energyCanvas.sortingLayerName; canvas.sortingOrder = energyCanvas.sortingOrder; canvas.gameObject.layer = energyCanvas.gameObject.layer; } return(canvas); }
public void SetRadius(float radius) { _curvedCanvasSettings.SetRadius(radius); }