-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFileFixUtility.cs
More file actions
46 lines (38 loc) · 1.33 KB
/
FileFixUtility.cs
File metadata and controls
46 lines (38 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Text.RegularExpressions;
public class FileFixUtility : Editor
{
[MenuItem("Tools/Fix Photo Lab Files")]
public static void FixPhotoLabFiles()
{
FixPhotoLabWindowFile();
}
public static void RemoveLastMethodCall()
{
FixPhotoLabWindowFile();
}
private static void FixPhotoLabWindowFile()
{
string filePath = "Assets/PhotoLab/Editor/PhotoLabWindow.cs";
string fullPath = Path.GetFullPath(filePath);
if (File.Exists(fullPath))
{
// Read the entire file
string content = File.ReadAllText(fullPath);
// Remove the problematic line
content = Regex.Replace(content, @"\s*\/\/ Call this method from toolbar when this tool becomes active\s*", "\n");
content = Regex.Replace(content, @"\s*EnsureHexInputFocus\(\);\s*", "\n");
// Write the fixed content back
File.WriteAllText(fullPath, content);
Debug.Log("PhotoLabWindow.cs file fixed successfully!");
// Trigger a recompile
AssetDatabase.ImportAsset(filePath);
}
else
{
Debug.LogError("Could not find file: " + fullPath);
}
}
}