Skip to content

Commit 75bf3be

Browse files
committed
Unimportant changes
1 parent d9ebea1 commit 75bf3be

File tree

5 files changed

+50
-18
lines changed

5 files changed

+50
-18
lines changed

Editor/Scripts/CodeExecutorManager.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88
namespace ChenPipi.CodeExecutor.Editor
99
{
1010

11-
/// <summary>
12-
/// 执行模式
13-
/// </summary>
14-
public struct ExecutionMode
15-
{
16-
public string name;
17-
public string desc;
18-
public Func<string, object[]> executor;
19-
}
20-
2111
/// <summary>
2212
/// 管理器
2313
/// </summary>
@@ -150,7 +140,7 @@ private static void NotifyOfDataUpdated()
150140

151141
#endregion
152142

153-
#region Data Operation
143+
#region Data: Snippets
154144

155145
/// <summary>
156146
/// 设置执行模式
@@ -251,7 +241,7 @@ public static void RemoveSnippets(string[] guids)
251241

252242
#endregion
253243

254-
#region Data Operation Snippet
244+
#region Data: Snippet Info
255245

256246
/// <summary>
257247
/// 代码段名称非法字符
@@ -578,4 +568,27 @@ internal static string GetNonDuplicateName(string name)
578568

579569
}
580570

571+
/// <summary>
572+
/// 执行模式
573+
/// </summary>
574+
public struct ExecutionMode
575+
{
576+
577+
/// <summary>
578+
/// 名称
579+
/// </summary>
580+
public string name;
581+
582+
/// <summary>
583+
/// 描述
584+
/// </summary>
585+
public string desc;
586+
587+
/// <summary>
588+
/// 执行函数
589+
/// </summary>
590+
public Func<string, object[]> executor;
591+
592+
}
593+
581594
}

Editor/Scripts/Window/Content/CodeExecutorWindowDetail.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,28 @@ private string ParseCode(string snippetName, string codeText)
137137
{
138138
return codeText;
139139
}
140+
// 处理导入
141+
return ProcessImport(snippetName, codeText);
142+
}
143+
144+
#region Syntax: Import
145+
146+
/// <summary>
147+
/// 导入语法模板
148+
/// </summary>
149+
private const string k_ImportSyntaxPattern = "@import\\s*\\(?[\"\']([^\"\']+)[\"\']\\)?";
140150

141-
const string importPattern = @"@import\s*[(]?[""']([^""']+)[""']\)?";
142-
string result = Regex.Replace(codeText, importPattern, match =>
151+
/// <summary>
152+
/// 处理导入
153+
/// </summary>
154+
/// <param name="snippetName"></param>
155+
/// <param name="codeText"></param>
156+
/// <returns></returns>
157+
private string ProcessImport(string snippetName, string codeText)
158+
{
159+
string result = Regex.Replace(codeText, k_ImportSyntaxPattern, match =>
143160
{
144-
string importName = match.Groups[1].Value;
161+
string importName = match.Groups[1].Value.Trim();
145162
if (string.IsNullOrWhiteSpace(importName))
146163
{
147164
return string.Empty;
@@ -172,6 +189,8 @@ private string ParseCode(string snippetName, string codeText)
172189
return result;
173190
}
174191

192+
#endregion
193+
175194
}
176195

177196
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Then we import the "CrazyThursday" snippet in other code using the import syntax
181181
UnityEngine.Debug.LogError("[CodeExecutor] V Me 50");
182182
```
183183

184-
the code will be parsed as:
184+
The code will be parsed as:
185185

186186
```csharp
187187
UnityEngine.Debug.LogError("[CodeExecutor] Crazy Thursday");

README_ZH.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ public static class Example
153153

154154
### 快速复制/粘贴代码段
155155

156-
- 键盘按下 Ctrl+C 组合键,即可将当前代码段列表中选择的代码段以 Json 格式文本的方式保存到系统剪贴板
157-
- 键盘按下 Ctrl+V 组合键,将会尝试解析系统剪贴板中的内容,并将有效的代码段保存到代码段列表中
156+
- 键盘按下 **Ctrl+C** 组合键,即可将当前代码段列表中选择的代码段以 Json 格式文本的方式保存到系统剪贴板
157+
- 键盘按下 **Ctrl+V** 组合键,将会尝试解析系统剪贴板中的内容,并将有效的代码段保存到代码段列表中
158158

159159
你可以通过这种方式来快速地在不同的 Unity 编辑器间交换代码段。
160160

-2.47 KB
Loading

0 commit comments

Comments
 (0)