2026-04-27 BGM 및 이스터에그

This commit is contained in:
2026-04-27 17:47:44 +09:00
parent 88a71e6292
commit 18d3077cc4
840 changed files with 53720 additions and 4 deletions

View File

@@ -0,0 +1,208 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
namespace TinyGiantStudio.Text
{
/// <summary>
/// This is used by the asset to store default settings shared by different scripts
/// Default File location: Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Utility/M3D Editor Settings.asset
/// </summary>
//[CreateAssetMenu(menuName = "Tiny Giant Studio/Modular 3d Text/Settings")]
public class AssetSettings : ScriptableObject
{
[HideInInspector] public string selectedTab = "Getting Started";
public Color tabSelectedColor = new Color(176f / 255f, 175f / 255, 175f / 255f);
public Color tabUnselectedColor = new Color(120f / 255f, 116f / 255f, 116f / 255f);
[Space]
public Color gridItemColor = new Color(185f / 255f, 184f / 255f, 184f / 255f);
public Color importantLabelColor_darkSkin = new Color(255f / 255f, 204f / 255f, 128f / 255f);
public Color importantLabelColor_lightSkin = new Color(159f / 255f, 97f / 255f, 7f / 255f);
public Color openedFoldoutTitleColor_darkSkin = new Color(240f / 255f, 241f / 255f, 101f / 255f);
public Color openedFoldoutTitleColor_lightSkin = new Color(123 / 255f, 120 / 255f, 1 / 255f);
//Text
public Font defaultFont = null;
public Vector3 defaultTextSize = new Vector3(8, 8, 8);
public Material defaultTextMaterial = null;
//Button
public Vector3 defaultButtonNormalTextSize = new Vector3(8, 8, 8);
public Material defaultButtonNormalTextMaterial = null;
public Material defaultButtonNormalBackgroundMaterial = null;
public Vector3 defaultButtonSelectedTextSize = new Vector3(8.2f, 8.2f, 8.2f);
public Material defaultButtonSelectedTextMaterial = null;
public Material defaultButtonSelectedBackgroundMaterial = null;
public Vector3 defaultButtonPressedTextSize = new Vector3(8.2f, 8.2f, 5);
public Material defaultButtonPressedTextMaterial = null;
public Material defaultButtonPressedBackgroundMaterial = null;
public Vector3 defaultButtonDisabledTextSize = new Vector3(8.2f, 8.2f, 5);
public Material defaultButtonDisabledTextMaterial = null;
public Material defaultButtonDisabledBackgroundMaterial = null;
//List
public Vector3 defaultListNormalTextSize = new Vector3(8, 8, 2);
public Material defaultListNormalTextMaterial = null;
public Material defaultListNormalBackgroundMaterial = null;
public Vector3 defaultListSelectedTextSize = new Vector3(8.2f, 8.2f, 5);
public Material defaultListSelectedTextMaterial = null;
public Material defaultListSelectedBackgroundMaterial = null;
public Vector3 defaultListPressedTextSize = new Vector3(8.2f, 8.2f, 5);
public Material defaultListPressedTextMaterial = null;
public Material defaultListPressedBackgroundMaterial = null;
public Vector3 defaultListDisabledTextSize = new Vector3(8.2f, 8.2f, 5);
public Material defaultListDisabledTextMaterial = null;
public Material defaultListDisabledBackgroundMaterial = null;
//[HideInInspector] public bool createLogTextFile = false;
//[HideInInspector] public bool createConsoleLogs = false;
[Header("Inspector field size")]
public float smallHorizontalFieldSize = 72.5f;
public float normalHorizontalFieldSize = 100;
public float largeHorizontalFieldSize = 132.5f;
public float extraLargeHorizontalFieldSize = 150f;
public enum MeshExportStyle
{
exportAsObj,
exportAsMeshAsset
}
#region Preferences
public bool autoCreateSceneInputSystem = true;
public bool dontAutoCreateRaycasterOrButtonIfVRtoolkitExists = true;
#endregion
#region Font creation
//font creation settings
public enum CharInputStyle
{
CharacterRange,
UnicodeRange,
CustomCharacters,
UnicodeSequence
//CharacterSet
}
public CharInputStyle charInputStyle;
public char startChar = '!'; //default '!'
public char endChar = '~'; //default '~'
public string startUnicode = "0021"; //default
[HideInInspector] public string endUnicode = "007E"; //default
[HideInInspector]
[TextArea(10, 99)]
public string customCharacters = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; //default
[HideInInspector]
[TextArea(10, 99)]
public string unicodeSequence = "\\u0021-\\u007E"; //default
[HideInInspector] public int vertexDensity = 1; //default 1
[HideInInspector] public float sizeXY = 1; //default 1
[HideInInspector] public float sizeZ = 1; //default 1
[HideInInspector] public int smoothingAngle = 30; //default 30
[HideInInspector] public MeshExportStyle meshExportStyle = MeshExportStyle.exportAsObj;
[HideInInspector] public int previewAmount;
#if ENABLE_INPUT_SYSTEM
[SerializeField] InputActionAsset _inputActionAsset;
public InputActionAsset InputActionAsset
{
get
{
if (_inputActionAsset == null)
{
FindModularTextInputActionAsset();
}
return _inputActionAsset;
}
set { _inputActionAsset = value; }
}
public void FindModularTextInputActionAsset()
{
#if UNITY_EDITOR //TODO //Unnecessary, but still writing it to be safe. Unnecessary because only editor scripts call the settings file to get input action asset
if (!_inputActionAsset)
{
string[] guids;
guids = AssetDatabase.FindAssets("t:inputActionAsset");
foreach (string guid in guids)
{
if (AssetDatabase.GUIDToAssetPath(guid).Contains("3D Text UI Controls.inputactions"))
{
InputActionAsset = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(InputActionAsset)) as InputActionAsset;
EditorUtility.SetDirty(this);
break;
}
}
}
#endif
}
#endif
public void ResetFontCreationMeshSettings()
{
vertexDensity = 1;
sizeXY = 1;
sizeZ = 1;
smoothingAngle = 30;
meshExportStyle = MeshExportStyle.exportAsObj;
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
public void ResetFontCreationPrebuiltSettings()
{
charInputStyle = CharInputStyle.CharacterRange;
startChar = '!';
endChar = '~';
startUnicode = "0021";
endUnicode = "007E";
customCharacters = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
unicodeSequence = "\\u0021-\\u007E";
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
#endregion
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 23fdc619dbf57034e8cbc426f77bfbfd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 247241
packageName: Modular 3D Text - In-Game 3D UI System
packageVersion: 4.9.2
assetPath: Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Scripts/Utilities/AssetSettings.cs
uploadId: 877966

View File

@@ -0,0 +1,425 @@
using System;
using TinyGiantStudio.Layout;
using UnityEditor;
using UnityEngine;
namespace TinyGiantStudio.Text
{
public class MenuItem : MonoBehaviour //MonoBehaviour is required for destroy immediate/instantiate etc.
{
#if UNITY_EDITOR
private static void CheckForRayCaster()
{
AssetSettings settings = StaticMethods.VerifySettings(null);
#if ENABLE_INPUT_SYSTEM
if (settings.InputActionAsset == null)
settings.FindModularTextInputActionAsset();
#endif
if (!settings.autoCreateSceneInputSystem)
return;
var xRToolkitGlobalInputControllerForModularTextAsset = Type.GetType("TinyGiantStudio.Text.XRToolkitGlobalInputControllerForModularTextAsset");
if (xRToolkitGlobalInputControllerForModularTextAsset != null)
{
#if UNITY_2023_1_OR_NEWER
var vrController = UnityEngine.Object.FindFirstObjectByType(Type.GetType("TinyGiantStudio.Text.XRToolkitGlobalInputControllerForModularTextAsset"));
//XRToolkitGlobalInputControllerForModularTextAsset vrController = (XRToolkitGlobalInputControllerForModularTextAsset)Object.FindFirstObjectByType(typeof(XRToolkitGlobalInputControllerForModularTextAsset), true);
#else
var vrController = GameObject.FindObjectOfType(Type.GetType("TinyGiantStudio.Text.XRToolkitGlobalInputControllerForModularTextAsset"), true);
#endif
if (vrController == null)
{
GameObject inputSystemGameObject = new GameObject("MText XR Input Manager");
Undo.RegisterCreatedObjectUndo(inputSystemGameObject, "Created MText XR Input Manager");
inputSystemGameObject.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
//inputSystemGameObject.AddComponent<XRToolkitGlobalInputControllerForModularTextAsset>();
inputSystemGameObject.AddComponent(xRToolkitGlobalInputControllerForModularTextAsset);
}
if (settings.dontAutoCreateRaycasterOrButtonIfVRtoolkitExists)
return;
}
#if UNITY_2023_1_OR_NEWER
RaycastSelector inputSystem = (RaycastSelector)UnityEngine.Object.FindFirstObjectByType(typeof(RaycastSelector), FindObjectsInactive.Include);
#else
RaycastSelector inputSystem = (RaycastSelector)GameObject.FindObjectOfType(typeof(RaycastSelector), true);
#endif
if (!inputSystem)
CreateRaycastSelector();
if (inputSystem) //TODO: //this is to update people's old scenes. Remove later, Added on march 2023
{
if (!inputSystem.gameObject.GetComponent<ButtonInputSystemGlobal>())
{
if (Application.isPlaying)
inputSystem.gameObject.AddComponent<ButtonInputSystemGlobal>();
else
Undo.AddComponent<ButtonInputSystemGlobal>(inputSystem.gameObject);
}
}
#if ENABLE_INPUT_SYSTEM
if (!inputSystem)
return;
EditorApplication.delayCall += () => UpdateInputActionAsset(settings, inputSystem);
#endif
}
#if ENABLE_INPUT_SYSTEM
private static void UpdateInputActionAsset(AssetSettings settings, RaycastSelector inputSystem)
{
ButtonInputSystemGlobal buttonInputSystemGlobal = inputSystem.gameObject.GetComponent<ButtonInputSystemGlobal>();
if (settings && buttonInputSystemGlobal)
{
if (settings.InputActionAsset && !buttonInputSystemGlobal.inputActionAsset)
{
buttonInputSystemGlobal.inputActionAsset = settings.InputActionAsset;
}
}
}
#endif
private static void CreateRaycastSelector()
{
GameObject inputSystemGameObject = new GameObject("M3D Input Manager");
Undo.RegisterCreatedObjectUndo(inputSystemGameObject, "Create M3D Input Manager");
inputSystemGameObject.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
inputSystemGameObject.AddComponent<RaycastSelector>();
inputSystemGameObject.AddComponent<RaycastInputProcessor>().myCamera = Camera.main;
inputSystemGameObject.AddComponent<ButtonInputSystemGlobal>();
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/Text", false, 20001)]
private static void CreateText(MenuCommand menuCommand)
{
// Create a custom game object
GameObject go = CreateText("Modular 3D Text");
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/List/Grid Layout", false, 20501)]
private static void CreateGridLayoutList(MenuCommand menuCommand)
{
CheckForRayCaster();
// Create a custom game object
GameObject go = new GameObject("List (M3D)");
go.AddComponent<List>();
go.GetComponent<List>().LoadDefaultSettings();
go.AddComponent<GridLayoutGroup>();
// Ensure it gets reparented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/List/Linear Layout", false, 20502)]
private static void CreateLinearLayoutList(MenuCommand menuCommand)
{
CheckForRayCaster();
// Create a custom game object
GameObject go = new GameObject("List (M3D)");
go.AddComponent<List>();
go.GetComponent<List>().LoadDefaultSettings();
go.AddComponent<LinearLayoutGroup>();
// Ensure it gets reparented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/List/Circular Layout", false, 20503)]
private static void CreateCircularLayoutList(MenuCommand menuCommand)
{
CheckForRayCaster();
// Create a custom game object
GameObject go = new GameObject("List (M3D)");
go.AddComponent<List>();
go.GetComponent<List>().LoadDefaultSettings();
go.AddComponent<CircularLayoutGroup>();
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/Button", false, 20002)]
private static void CreateButton(MenuCommand menuCommand)
{
CheckForRayCaster();
GameObject go = new GameObject("Button (M3D)");
GameObject text = CreateText("Button");
text.transform.SetParent(go.transform);
GameObject bg = GameObject.CreatePrimitive(PrimitiveType.Cube);
bg.name = "Background";
bg.transform.localScale = new Vector3(15, 2, 1);
if (bg.GetComponent<BoxCollider>())
DestroyImmediate(bg.GetComponent<BoxCollider>());
bg.transform.SetParent(go.transform);
bg.transform.localPosition = new Vector3(0, 0, 0.55f);
go.AddComponent<Button>();
go.GetComponent<Button>().Background = bg.GetComponent<Renderer>();
go.GetComponent<Button>().Text = text.GetComponent<Modular3DText>();
go.GetComponent<Button>().LoadDefaultSettings();
bg.GetComponent<Renderer>().material = go.GetComponent<Button>().NormalBackgroundMaterial;
go.AddComponent<BoxCollider>();
go.GetComponent<BoxCollider>().size = new Vector3(15, 2, 1);
go.GetComponent<BoxCollider>().center = new Vector3(0, 0, 0.5f);
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/Input Field", false, 20003)]
private static void CreateInputField(MenuCommand menuCommand)
{
CheckForRayCaster();
GameObject text = new GameObject("Text");
text.AddComponent<Modular3DText>();
text.AddComponent<GridLayoutGroup>();
LoadDefaultTextSettings(text.GetComponent<Modular3DText>());
//text.GetComponent<Modular3DText>().UpdateText("Input Field");
GameObject bg = GameObject.CreatePrimitive(PrimitiveType.Cube);
bg.name = "Background";
bg.transform.localScale = new Vector3(15, 2, 1);
if (bg.GetComponent<BoxCollider>())
DestroyImmediate(bg.GetComponent<BoxCollider>());
// Create a custom game object
GameObject go = new GameObject("Input Field (M3D)");
bg.transform.SetParent(go.transform);
bg.transform.localPosition = new Vector3(0, 0, 0.55f);
text.transform.SetParent(go.transform);
go.AddComponent<InputField>();
go.GetComponent<InputField>().background = bg.GetComponent<Renderer>();
bg.GetComponent<Renderer>().material = go.GetComponent<InputField>().normalBackgroundMaterial;
go.GetComponent<InputField>().textComponent = text.GetComponent<Modular3DText>();
go.GetComponent<InputField>().UpdateText();
go.AddComponent<BoxCollider>();
go.GetComponent<BoxCollider>().size = new Vector3(15, 2, 1);
go.GetComponent<BoxCollider>().center = new Vector3(0, 0, 0.5f);
// Ensure it gets reparented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/Slider", false, 20004)]
private static void CreateSlider(MenuCommand menuCommand)
{
CheckForRayCaster();
// Create a custom game object
GameObject go = new GameObject("Slider (M3D)");
go.AddComponent<Slider>();
Slider slider = go.GetComponent<Slider>();
GameObject handle = GameObject.CreatePrimitive(PrimitiveType.Cube);
handle.name = "Handle";
handle.AddComponent<SliderHandle>();
handle.GetComponent<SliderHandle>().slider = slider;
handle.transform.SetParent(go.transform);
handle.transform.localPosition = Vector3.zero;
slider.handle = handle.GetComponent<SliderHandle>();
slider.handleGraphic = handle.GetComponent<Renderer>();
handle.GetComponent<Renderer>().material = slider.unSelectedHandleMat;
GameObject bg = GameObject.CreatePrimitive(PrimitiveType.Cube);
bg.name = "Background";
bg.transform.SetParent(go.transform);
bg.transform.localPosition = Vector3.zero;
bg.transform.localScale = new Vector3(10, 0.25f, 0.25f);
slider.background = bg.transform;
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/Toggle", false, 20006)]
private static void CreateToggle(MenuCommand menuCommand)
{
CheckForRayCaster();
GameObject go = new GameObject("Toggle (M3D)");
Toggle toggle = go.AddComponent<Toggle>();
Button button = go.AddComponent<Button>();
go.AddComponent<BoxCollider>().size = new Vector3(3, 3, 1);
button.PressedBackgroundMaterial = button.SelectedBackgroundMaterial;
button.NormalTextSize = new Vector3(20, 20, 8);
button.SelectedTextSize = new Vector3(20, 20, 8.2f);
button.PressedTextSize = new Vector3(20, 20, 8.5f);
button.LoadDefaultSettings();
GameObject text = CreateText("X");
text.GetComponent<Modular3DText>().FontSize = new Vector3(20, 20, 8);
text.transform.SetParent(go.transform);
go.GetComponent<Button>().Text = text.GetComponent<Modular3DText>();
toggle.onGraphic = text;
GameObject bg = GameObject.CreatePrimitive(PrimitiveType.Cube);
bg.name = "Background";
bg.transform.localScale = new Vector3(3, 3, 1);
if (bg.GetComponent<BoxCollider>())
DestroyImmediate(bg.GetComponent<BoxCollider>());
bg.transform.SetParent(go.transform);
bg.transform.localPosition = new Vector3(0, 0, 0.55f);
button.Background = bg.GetComponent<Renderer>();
bg.GetComponent<Renderer>().material = go.GetComponent<Button>().NormalBackgroundMaterial;
//go.GetComponent<Toggle>().AddEventToButton();
button.pressCompleteEvent ??= new UnityEngine.Events.UnityEvent();
UnityEditor.Events.UnityEventTools.AddPersistentListener(
button.pressCompleteEvent,
toggle.ToggleState
);
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/Progress Bar", false, 20005)]
private static void CreateProgressBar(MenuCommand menuCommand)
{
CheckForRayCaster();
// Create a custom game object
GameObject go = new GameObject("ProgressBar (M3D)");
go.AddComponent<Slider>();
Slider slider = go.GetComponent<Slider>();
GameObject handle = GameObject.CreatePrimitive(PrimitiveType.Cube);
handle.name = "Handle";
handle.AddComponent<SliderHandle>();
handle.GetComponent<SliderHandle>().slider = slider;
handle.transform.SetParent(go.transform);
handle.transform.localPosition = Vector3.zero;
slider.handle = handle.GetComponent<SliderHandle>();
slider.handleGraphic = handle.GetComponent<Renderer>();
handle.GetComponent<Renderer>().material = slider.unSelectedHandleMat;
GameObject bg = GameObject.CreatePrimitive(PrimitiveType.Cube);
bg.name = "Background";
bg.transform.SetParent(go.transform);
bg.transform.localPosition = Vector3.zero;
bg.transform.localScale = new Vector3(10, 0.25f, 0.25f);
slider.background = bg.transform;
if (slider.progressBarPrefab)
{
GameObject progressBarGraphic = Instantiate(slider.progressBarPrefab);
slider.progressBar = progressBarGraphic.transform;
progressBarGraphic.transform.SetParent(go.transform);
progressBarGraphic.transform.localPosition = new Vector3(-5, 0, 0);
progressBarGraphic.transform.localScale = new Vector3(5, 0.8f, 0.8f);
}
else
{
Debug.Log("No progress bar prefab found. Please create one and assign it to Progressbar field");
}
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
[UnityEditor.MenuItem("GameObject/3D Object/Tiny Giant Studio/Modular 3D Text/Horizontal Selector", false, 20007)]
private static void CreateHorizontalSelector(MenuCommand menuCommand)
{
CheckForRayCaster();
// Create a custom game object
GameObject go = new GameObject("Horizontal Selector (M3D)");
go.AddComponent<HorizontalSelector>();
HorizontalSelector selector = go.GetComponent<HorizontalSelector>();
// Create a custom game object
GameObject text = new GameObject("Text (M3D)");
text.AddComponent<Modular3DText>();
text.AddComponent<GridLayoutGroup>();
if (!text.GetComponent<TextUpdater>()) text.AddComponent<TextUpdater>();
text.GetComponent<Modular3DText>().UpdateText("Option A");
LoadDefaultTextSettings(text.GetComponent<Modular3DText>());
text.transform.SetParent(go.transform);
text.transform.localPosition = Vector3.zero;
selector.text = text.GetComponent<Modular3DText>();
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
private static GameObject CreateText(string text)
{
GameObject go = new GameObject("Text (M3D)");
go.AddComponent<Modular3DText>();
go.AddComponent<GridLayoutGroup>();
go.GetComponent<Modular3DText>().Text = text;
if (!go.GetComponent<TextUpdater>())
go.AddComponent<TextUpdater>();
LoadDefaultTextSettings(go.GetComponent<Modular3DText>());
return go;
}
private static void LoadDefaultTextSettings(Modular3DText text)
{
AssetSettings settings = StaticMethods.VerifySettings(null);
if (settings)
{
text.Font = settings.defaultFont;
text.FontSize = settings.defaultTextSize;
text.Material = settings.defaultTextMaterial;
}
}
#endif
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: a3f943abd34f2e24ca32c7288453530f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- buttonPrefab: {fileID: 8377934228991207282, guid: 814da704eb23f254dbc9f81107012e02,
type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 247241
packageName: Modular 3D Text - In-Game 3D UI System
packageVersion: 4.9.2
assetPath: Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Scripts/Utilities/MenuItem.cs
uploadId: 877966

View File

@@ -0,0 +1,152 @@
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
using TinyGiantStudio.Layout;
namespace TinyGiantStudio.Text
{
public static class MeshCombiner
{
public static List<Mesh> CombinedMesh(List<MeshLayout> meshLayouts, Vector3 scale, bool useIncreasedVerticiesCountForCombinedMesh)
{
if (meshLayouts == null)
return null;
List<List<MeshLayout>> meshFiltersUpperList = new List<List<MeshLayout>>();
int listNumber = 0;
List<MeshLayout> firstList = new List<MeshLayout>();
meshFiltersUpperList.Add(firstList);
bool tooMuchVerts = false;
int verteciesCount = 0;
for (int j = 0; j < meshLayouts.Count; j++)
{
if (meshLayouts[j].mesh)
{
if (meshLayouts[j].mesh.isReadable)
{
if (useIncreasedVerticiesCountForCombinedMesh || verteciesCount + meshLayouts[j].mesh.vertices.Length < 65535)
{
verteciesCount += meshLayouts[j].mesh.vertices.Length;
meshFiltersUpperList[listNumber].Add(meshLayouts[j]);
if (verteciesCount + meshLayouts[j].mesh.vertices.Length >= 65535)
tooMuchVerts = true;
}
else
{
verteciesCount = 0;
List<MeshLayout> newList = new List<MeshLayout>();
meshFiltersUpperList.Add(newList);
listNumber++;
verteciesCount += meshLayouts[j].mesh.vertices.Length;
meshFiltersUpperList[listNumber].Add(meshLayouts[j]);
}
}
else
{
Debug.LogError(meshLayouts[j].mesh + " mesh isReadable is set to false. Read/Write must be enabled on import settings.");
}
}
}
List<Mesh> combinedMeshes = new List<Mesh>();
for (int k = 0; k < meshFiltersUpperList.Count; k++)
{
CombineInstance[] combine = new CombineInstance[meshFiltersUpperList[k].Count];
int i = 0;
while (i < meshFiltersUpperList[k].Count)
{
combine[i].mesh = meshFiltersUpperList[k][i].mesh;
Matrix4x4 m = Matrix4x4.TRS(
RemoveNaNAndInfinityErrorIfAny(meshFiltersUpperList[k][i].position),
RemoveNaNAndInfinityErrorIfAny(meshFiltersUpperList[k][i].rotation),
scale);
combine[i].transform = m;
i++;
}
List<CombineInstance> combinedList = new List<CombineInstance>();
for (int j = 0; j < combine.Length; j++)
{
if (combine[j].mesh != null)
combinedList.Add(combine[j]);
}
combine = combinedList.ToArray();
Mesh finalMesh = new Mesh();
if (useIncreasedVerticiesCountForCombinedMesh && tooMuchVerts)
finalMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
finalMesh.CombineMeshes(combine);
combinedMeshes.Add(finalMesh);
}
return combinedMeshes;
}
public static Vector3 RemoveNaNAndInfinityErrorIfAny(Vector3 vector3)
{
if (float.IsNaN(vector3.x) || float.IsInfinity(vector3.x))
vector3.x = 0;
if (float.IsNaN(vector3.y) || float.IsInfinity(vector3.y))
vector3.y = 0;
if (float.IsNaN(vector3.z) || float.IsInfinity(vector3.z))
vector3.z = 0;
return vector3;
}
public static Quaternion RemoveNaNAndInfinityErrorIfAny(Quaternion quaternion)
{
if (float.IsNaN(quaternion.x) || float.IsInfinity(quaternion.x))
quaternion.x = 0;
if (float.IsNaN(quaternion.y) || float.IsInfinity(quaternion.y))
quaternion.y = 0;
if (float.IsNaN(quaternion.z) || float.IsInfinity(quaternion.z))
quaternion.z = 0;
return quaternion;
}
#if UNITY_EDITOR
//todo
private static (bool, bool) CheckDirty(GameObject gameObject)
{
bool positionDirty = false;
bool rotationDirty = false;
if (!PrefabUtility.IsPartOfAnyPrefab(gameObject))
return (positionDirty, rotationDirty);
var modifications = PrefabUtility.GetPropertyModifications(gameObject);
for (int i = 0; i < modifications.Length; i++)
{
if (modifications[i] != null)
{
#if UNITY_2018_3_OR_NEWER
if (PrefabUtility.IsDefaultOverride(modifications[i])) continue;
#endif
if (modifications[i].propertyPath.Contains("m_LocalPosition"))
positionDirty = true;
if (modifications[i].propertyPath.Contains("m_LocalRotation"))
rotationDirty = true;
}
}
return (positionDirty, rotationDirty);
}
#endif
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4521f1caad74a8c4381fc0b1f422f9b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 247241
packageName: Modular 3D Text - In-Game 3D UI System
packageVersion: 4.9.2
assetPath: Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Scripts/Utilities/MeshCombiner.cs
uploadId: 877966

View File

@@ -0,0 +1,81 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace TinyGiantStudio.Text
{
/// <summary>
/// This class contains different reusable methods for the asset
/// </summary>
public class StaticMethods
{
/// <summary>
/// Returns if an item has a List as parent
/// </summary>
/// <param name="transform">The transform being checked</param>
/// <returns></returns>
public static List GetParentList(Transform transform)
{
if (transform.parent == null)
return null;
if (transform.parent.GetComponent<List>())
{
return transform.parent.GetComponent<List>();
}
else return null;
}
#if UNITY_EDITOR
/// <summary>
/// Editor Only!
/// </summary>
/// <param name="mesh"></param>
public static void OptimizeMesh(Mesh mesh)
{
MeshUtility.Optimize(mesh);
}
public static string settingFileLocation = "Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Utility/M3D Editor Settings.asset";
public static AssetSettings VerifySettings(AssetSettings settings)
{
//Debug.Log("Verifying settings");
if (settings)
return settings;
AssetSettings mySettings = EditorGUIUtility.Load(settingFileLocation) as AssetSettings;
//AssetSettings mySettings = Resources.Load("Modular 3D Text/M Text_Settings") as AssetSettings;
if (mySettings)
return mySettings;
var objects = Resources.FindObjectsOfTypeAll(typeof(AssetSettings));
if (objects.Length > 1)
{
Debug.LogWarning("Multiple MText_Settings files have been found. Please make sure only one exists to avoid unexpected behavior");
for (int i = 0; i < objects.Length; i++)
{
Debug.Log("Setting file " + (i + 1) + " : " + AssetDatabase.GetAssetPath(objects[i]));
}
return (AssetSettings)objects[0];
}
else if (objects.Length == 0)
{
Debug.Log("Creating editor settings file for Modular 3D Text.");
AssetSettings asset = ScriptableObject.CreateInstance<AssetSettings>();
AssetDatabase.CreateAsset(asset, settingFileLocation);
AssetDatabase.SaveAssets();
Debug.Log("Editor settings file for Modular 3D Text has been successfully created: " + settingFileLocation + "\nYou can modify settings from Tools>Tiny Giant Studio/Modular 3D Text");
return asset;
}
else
{
return (AssetSettings)objects[0];
}
}
#endif
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1c21d922e06cfdc43aeda03e33badc08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 247241
packageName: Modular 3D Text - In-Game 3D UI System
packageVersion: 4.9.2
assetPath: Assets/Plugins/Tiny Giant Studio/Modular 3D Text/Scripts/Utilities/StaticMethods.cs
uploadId: 877966