diff --git a/Custom Menu Text/Beon b/Custom Menu Text/Beon
new file mode 100644
index 0000000..bc06e09
Binary files /dev/null and b/Custom Menu Text/Beon differ
diff --git a/Custom Menu Text/CustomMenuText.csproj b/Custom Menu Text/CustomMenuText.csproj
index 92d4c39..17a907c 100644
--- a/Custom Menu Text/CustomMenuText.csproj
+++ b/Custom Menu Text/CustomMenuText.csproj
@@ -48,13 +48,16 @@
-
- False
- C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\TextMeshPro-1.0.55.2017.1.0b12.dll
+
+ ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Unity.TextMeshPro.dll
C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll
+
+ False
+ ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AssetBundleModule.dll
+
C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll
@@ -65,6 +68,20 @@
+
+ True
+ True
+ Resources.resx
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
diff --git a/Custom Menu Text/CustomMenuTextPlugin.cs b/Custom Menu Text/CustomMenuTextPlugin.cs
index e8500f1..f93596d 100644
--- a/Custom Menu Text/CustomMenuTextPlugin.cs
+++ b/Custom Menu Text/CustomMenuTextPlugin.cs
@@ -1,27 +1,30 @@
-using System;
+using IllusionPlugin;
+using System;
using System.Collections.Generic;
-using System.Linq;
using System.IO;
+using System.Linq;
+using System.Text;
+using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
-using IllusionPlugin;
-using TMPro;
-using System.Text;
-namespace TestBSPlugin
+namespace CustomMenuText
{
public class CustomMenuTextPlugin : IPlugin
{
// path to the file to load text from
private const string FILE_PATH = "/UserData/CustomMenuText.txt";
- public static TMP_FontAsset beon;
+ // path to load the font prefab from
+ private const string FONT_PATH = "UserData/CustomMenuFont";
+ // prefab to instantiate when creating the TextMeshPros
+ public static GameObject textPrefab;
// used if we can't load any custom entries
public static readonly string[] DEFAULT_TEXT = { "BEAT", "SABER" };
public static readonly Color defaultMainColor = new Color(0, 0.5019608f, 1);
public static readonly Color defaultBottomColor = Color.red;
public const string DEFAULT_CONFIG =
-@"# Custom Menu Text v2.2.0
+@"# Custom Menu Text v3.0.0
# by Arti
# Special Thanks: Kyle1413
#
@@ -42,7 +45,7 @@ public class CustomMenuTextPlugin : IPlugin
# You can override the colors even when the text is 2 lines, plus do a lot of other stuff!
# (contributed by @Rolo)
<#ffffff>SBU<#ffff00>BBY
- <#1E5142>eef freef.
+ <#1E5142>eef freef.
# Some more random messages:
BEAT
@@ -159,7 +162,7 @@ Ask in <#7289DA>#support
public static List allEntries = null;
public string Name => "Custom Menu Text";
- public string Version => "2.2.0";
+ public string Version => "3.0.0";
// Store the text objects so when we leave the menu and come back, we aren't creating a bunch of them
public static TextMeshPro mainText;
@@ -173,7 +176,7 @@ public void OnApplicationStart()
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
{
- if (arg1.name == "Menu") // Only run in menu scene
+ if (arg1.name == "MenuCore") // Only run in menu scene
{
if (allEntries == null)
{
@@ -204,6 +207,25 @@ private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
}
+ public static GameObject loadTextPrefab(string path)
+ {
+ GameObject prefab;
+ string fontPath = Path.Combine(Environment.CurrentDirectory, path);
+ if (!File.Exists(fontPath))
+ {
+ File.WriteAllBytes(fontPath, Properties.Resources.Beon);
+ }
+ AssetBundle fontBundle = AssetBundle.LoadFromFile(fontPath);
+ prefab = fontBundle.LoadAsset("Text");
+ if (prefab == null)
+ {
+ Console.WriteLine("[CustomMenuText] No text prefab found in the provided AssetBundle! Using Beon.");
+ AssetBundle beonBundle = AssetBundle.LoadFromMemory(Properties.Resources.Beon);
+ prefab = beonBundle.LoadAsset("Text");
+ }
+ return prefab;
+ }
+
public static List readFromFile(string relPath)
{
List entriesInFile = new List();
@@ -279,33 +301,27 @@ public static List readFromFile(string relPath)
///
public static void replaceLogo()
{
- if (beon == null)
- {
- var fonts = Resources.FindObjectsOfTypeAll();
- foreach (TMP_FontAsset font in fonts)
- {
- if (font.name == "Beon SDF")
- beon = font;
- }
- }
+ // Since 0.13.0, we have to create our TextMeshPros differently! You can't change the font at runtime, so we load a prefab with the right font from an AssetBundle. This has the side effect of allowing for custom fonts, an oft-requested feature.
+ if (textPrefab == null) textPrefab = loadTextPrefab(FONT_PATH);
// Logo Top Pos : 0.63, 21.61, 24.82
// Logo Bottom Pos : 0, 17.38, 24.82
-
if (mainText == null) mainText = GameObject.Find("CustomMenuText")?.GetComponent();
if (mainText == null)
{
- GameObject textObj = new GameObject("CustomMenuText");
- mainText = textObj.AddComponent();
+ GameObject textObj = GameObject.Instantiate(textPrefab);
+ textObj.name = "CustomMenuText";
+ textObj.SetActive(false);
+ mainText = textObj.GetComponent();
mainText.alignment = TextAlignmentOptions.Center;
mainText.fontSize = 12;
- mainText.font = beon;
mainText.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 2f);
mainText.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 2f);
mainText.richText = true;
textObj.transform.localScale *= 3.7f;
mainText.overflowMode = TextOverflowModes.Overflow;
mainText.enableWordWrapping = false;
+ textObj.SetActive(true);
}
mainText.rectTransform.position = new Vector3(0f, 21.61f, 24.82f);
mainText.color = defaultMainColor;
@@ -314,24 +330,26 @@ public static void replaceLogo()
if (bottomText == null) bottomText = GameObject.Find("CustomMenuText-Bot")?.GetComponent();
if (bottomText == null)
{
- GameObject textObj2 = new GameObject("CustomMenuText-Bot");
- bottomText = textObj2.AddComponent();
+ GameObject textObj2 = GameObject.Instantiate(textPrefab);
+ textObj2.name = "CustomMenuText-Bot";
+ textObj2.SetActive(false);
+ bottomText = textObj2.GetComponent();
bottomText.alignment = TextAlignmentOptions.Center;
bottomText.fontSize = 12;
- bottomText.font = beon;
bottomText.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 2f);
bottomText.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 2f);
bottomText.richText = true;
textObj2.transform.localScale *= 3.7f;
bottomText.overflowMode = TextOverflowModes.Overflow;
bottomText.enableWordWrapping = false;
+ textObj2.SetActive(true);
}
bottomText.rectTransform.position = new Vector3(0f, 17f, 24.82f);
bottomText.color = defaultBottomColor;
mainText.text = "SABER";
// Destroy Default Logo
- GameObject defaultLogo = GameObject.Find("Logo");
+ GameObject defaultLogo = FindUnityObjectsHelper.GetAllGameObjectsInLoadedScenes().Where(go => go.name == "Logo").FirstOrDefault();
if (defaultLogo != null) GameObject.Destroy(defaultLogo);
}
diff --git a/Custom Menu Text/Properties/AssemblyInfo.cs b/Custom Menu Text/Properties/AssemblyInfo.cs
index 2bc3643..0328968 100644
--- a/Custom Menu Text/Properties/AssemblyInfo.cs
+++ b/Custom Menu Text/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("3.0.0.0")]
+[assembly: AssemblyFileVersion("3.0.0.0")]
diff --git a/Custom Menu Text/Properties/Resources.Designer.cs b/Custom Menu Text/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..1dc69cd
--- /dev/null
+++ b/Custom Menu Text/Properties/Resources.Designer.cs
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace CustomMenuText.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CustomMenuText.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Byte[].
+ ///
+ internal static byte[] Beon {
+ get {
+ object obj = ResourceManager.GetObject("Beon", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+ }
+}
diff --git a/Custom Menu Text/Properties/Resources.resx b/Custom Menu Text/Properties/Resources.resx
new file mode 100644
index 0000000..5becc02
--- /dev/null
+++ b/Custom Menu Text/Properties/Resources.resx
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Beon;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file