Initial commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ac587d2a0276414eba180f326e2e047
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
// #define AUTO_INCREMENT_BUILD
|
||||
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
|
||||
#if AUTO_INCREMENT_BUILD
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
public class BuildIdIncrementer : IPreprocessBuildWithReport, IPostprocessBuildWithReport
|
||||
{
|
||||
public int callbackOrder => 0;
|
||||
|
||||
#if AUTO_INCREMENT_BUILD
|
||||
/// <summary>
|
||||
/// The version code to increment. Determines the index of the version number to increment.
|
||||
/// </summary>
|
||||
int m_VersionCode = 2;
|
||||
bool m_UpdatingBuildId = false;
|
||||
#endif
|
||||
|
||||
public void OnPostprocessBuild(BuildReport report)
|
||||
{
|
||||
#if AUTO_INCREMENT_BUILD
|
||||
if(m_UpdatingBuildId)
|
||||
{
|
||||
m_UpdatingBuildId = false;
|
||||
XRMultiplayer.Utils.Log($"Build Auto Updated: {PlayerSettings.bundleVersion}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
#if AUTO_INCREMENT_BUILD
|
||||
m_UpdatingBuildId = true;
|
||||
string[] currentVersion = Application.version.Split('.');
|
||||
if (currentVersion.Length == m_VersionCode + 1)
|
||||
{
|
||||
if (int.TryParse(currentVersion[m_VersionCode], out int result))
|
||||
{
|
||||
result++;
|
||||
}
|
||||
|
||||
PlayerSettings.bundleVersion = $"{currentVersion[0]}.{currentVersion[1]}.{result}";
|
||||
|
||||
#if UNITY_ANDROID
|
||||
PlayerSettings.Android.bundleVersionCode = result;
|
||||
#endif
|
||||
}
|
||||
|
||||
XRMultiplayer.Utils.Log($"Updating Build ID: {PlayerSettings.bundleVersion}");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7968529ed76e9c146bb0a7f87663ab87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class MeshSaver
|
||||
{
|
||||
[MenuItem("CONTEXT/MeshFilter/Save Mesh...")]
|
||||
public static void SaveMeshInPlace(MenuCommand menuCommand)
|
||||
{
|
||||
MeshFilter mf = menuCommand.context as MeshFilter;
|
||||
Mesh m = mf.sharedMesh;
|
||||
SaveMesh(m, m.name, false, true);
|
||||
}
|
||||
|
||||
[MenuItem("CONTEXT/MeshFilter/Save Mesh As New Instance...")]
|
||||
public static void SaveMeshNewInstanceItem(MenuCommand menuCommand)
|
||||
{
|
||||
MeshFilter mf = menuCommand.context as MeshFilter;
|
||||
Mesh m = mf.sharedMesh;
|
||||
SaveMesh(m, m.name, true, true);
|
||||
}
|
||||
|
||||
public static void SaveMesh(Mesh mesh, string name, bool makeNewInstance, bool optimizeMesh)
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanel("Save Separate Mesh Asset", "Assets/", name, "asset");
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
|
||||
path = FileUtil.GetProjectRelativePath(path);
|
||||
|
||||
Mesh meshToSave = (makeNewInstance) ? Object.Instantiate(mesh) as Mesh : mesh;
|
||||
|
||||
if (optimizeMesh)
|
||||
MeshUtility.Optimize(meshToSave);
|
||||
|
||||
AssetDatabase.CreateAsset(meshToSave, path);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b235d5962bd92d4db7167e5b3850639
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,146 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TextConverter : MonoBehaviour
|
||||
{
|
||||
[MenuItem("Tools/Update Legacy Text")]
|
||||
static void UpdateLegacyText()
|
||||
{
|
||||
Debug.Log("Converting Legacy Text to TMP");
|
||||
Text[] allText = FindObjectsByType<Text>(FindObjectsSortMode.None);
|
||||
Debug.Log($"Found {allText.Length} Legacy Text{(allText.Length > 1 ? "s" : "")}");
|
||||
List<TextMigrator> migratorList = new List<TextMigrator>();
|
||||
foreach (var t in allText)
|
||||
{
|
||||
|
||||
TextMigrator migrator = new TextMigrator()
|
||||
{
|
||||
transform = t.transform,
|
||||
textValue = t.text,
|
||||
textSize = t.fontSize,
|
||||
autoSize = t.resizeTextForBestFit,
|
||||
textAlignment = t.alignment,
|
||||
};
|
||||
if (migrator.autoSize)
|
||||
{
|
||||
migrator.minSize = t.resizeTextMinSize;
|
||||
migrator.maxSize = t.resizeTextMaxSize;
|
||||
}
|
||||
migratorList.Add(migrator);
|
||||
DestroyImmediate(t);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var migrator in migratorList)
|
||||
{
|
||||
sb.AppendLine($" -Migrating {migrator.textValue} to TMP");
|
||||
TMP_Text tmp = migrator.transform.gameObject.AddComponent<TextMeshProUGUI>();
|
||||
tmp.text = migrator.textValue;
|
||||
tmp.fontSize = migrator.textSize;
|
||||
|
||||
TMPAlignment alignment = GetAlignment(migrator.textAlignment);
|
||||
tmp.verticalAlignment = alignment.verticalAlignment;
|
||||
tmp.horizontalAlignment = alignment.horizontalAlignment;
|
||||
|
||||
if (migrator.autoSize)
|
||||
{
|
||||
tmp.enableAutoSizing = true;
|
||||
tmp.fontSizeMin = migrator.minSize;
|
||||
tmp.fontSizeMax = migrator.maxSize;
|
||||
}
|
||||
}
|
||||
Debug.Log($"Legacy Text to TMP Conversion Complete\nUpdated Texts:\n{sb}");
|
||||
}
|
||||
|
||||
static TMPAlignment GetAlignment(TextAnchor anchor)
|
||||
{
|
||||
switch (anchor)
|
||||
{
|
||||
case TextAnchor.UpperCenter:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Center,
|
||||
verticalAlignment = VerticalAlignmentOptions.Top
|
||||
};
|
||||
case TextAnchor.UpperLeft:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Left,
|
||||
verticalAlignment = VerticalAlignmentOptions.Top
|
||||
};
|
||||
case TextAnchor.UpperRight:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Right,
|
||||
verticalAlignment = VerticalAlignmentOptions.Top
|
||||
};
|
||||
|
||||
case TextAnchor.MiddleCenter:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Center,
|
||||
verticalAlignment = VerticalAlignmentOptions.Middle
|
||||
};
|
||||
case TextAnchor.MiddleLeft:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Left,
|
||||
verticalAlignment = VerticalAlignmentOptions.Middle
|
||||
};
|
||||
case TextAnchor.MiddleRight:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Right,
|
||||
verticalAlignment = VerticalAlignmentOptions.Middle
|
||||
};
|
||||
|
||||
case TextAnchor.LowerCenter:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Center,
|
||||
verticalAlignment = VerticalAlignmentOptions.Bottom
|
||||
};
|
||||
case TextAnchor.LowerLeft:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Left,
|
||||
verticalAlignment = VerticalAlignmentOptions.Bottom
|
||||
};
|
||||
case TextAnchor.LowerRight:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Right,
|
||||
verticalAlignment = VerticalAlignmentOptions.Bottom
|
||||
};
|
||||
|
||||
|
||||
default:
|
||||
return new TMPAlignment()
|
||||
{
|
||||
horizontalAlignment = HorizontalAlignmentOptions.Left,
|
||||
verticalAlignment = VerticalAlignmentOptions.Top
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct TextMigrator
|
||||
{
|
||||
public Transform transform;
|
||||
public string textValue;
|
||||
public int textSize;
|
||||
public bool autoSize;
|
||||
public int minSize;
|
||||
public int maxSize;
|
||||
public TextAnchor textAlignment;
|
||||
}
|
||||
|
||||
public struct TMPAlignment
|
||||
{
|
||||
public HorizontalAlignmentOptions horizontalAlignment;
|
||||
public VerticalAlignmentOptions verticalAlignment;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 114e3cba64f0fc547b1cd55a85d78d8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user