Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if UNITY_EDITOR && (UNITY_2018_1 || UNITY_2018_2)
- namespace UIWidgets
- {
- using System;
- using System.IO;
- using System.Linq;
- using UnityEditor;
- public static class TextMeshProSupportFix
- {
- [MenuItem("Edit/Project Settings/New UI Widgets/Fix TextMesh Pro support files", false, 1100)]
- public static void RemoveForceRecompile()
- {
- RemoveForceRecompileByLabel("TMProFolder");
- }
- public static bool RemoveForceRecompileByLabel(string label)
- {
- var path = Utilites.GetAssetPath(label);
- if (path == null)
- {
- return false;
- }
- if (Directory.Exists(path))
- {
- RemoveForceRecompileFolder(path);
- }
- else
- {
- RemoveForceRecompileFile(path);
- }
- return true;
- }
- static void RemoveForceRecompileFolder(string path)
- {
- var dir = new DirectoryInfo(path);
- var files = dir.GetFiles("*.cs", SearchOption.AllDirectories);
- foreach (var file in files)
- {
- RemoveForceRecompileFile(file.FullName);
- }
- AssetDatabase.Refresh();
- }
- static void RemoveForceRecompileFile(string filepath)
- {
- var lines = File.ReadAllLines(filepath).ToList();
- var prefix = "// Force script reload at ";
- if (lines[lines.Count - 1].StartsWith(prefix))
- {
- lines.RemoveAt(lines.Count - 1);
- File.WriteAllText(filepath, string.Join("\r\n", lines.ToArray()));
- File.SetLastWriteTimeUtc(filepath, DateTime.UtcNow);
- }
- }
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement