Skip to content

Commit 7a497ad

Browse files
committed
First commit.
0 parents  commit 7a497ad

File tree

109 files changed

+6915
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+6915
-0
lines changed

.gitignore

Whitespace-only changes.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## [1.0.0] - 2023-08-20
4+
5+
- Release

CHANGELOG.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "ChenPipi.CodeExecutor.Editor",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
6+
"GUID:2bafac87e7f4b9b418d9448d219b01ab"
7+
],
8+
"includePlatforms": [
9+
"Editor"
10+
],
11+
"excludePlatforms": [],
12+
"allowUnsafeCode": false,
13+
"overrideReferences": false,
14+
"precompiledReferences": [],
15+
"autoReferenced": true,
16+
"defineConstraints": [],
17+
"versionDefines": [],
18+
"noEngineReferences": false
19+
}

Editor/ChenPipi.CodeExecutor.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Scripts.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Scripts/Attributes.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Reflection;
4+
using JetBrains.Annotations;
5+
using UnityEditor;
6+
7+
namespace ChenPipi.CodeExecutor.Editor
8+
{
9+
10+
/// <summary>
11+
/// 用于注册 Code Executor 执行模式的 Attribute,提供了控制函数执行顺序的能力,来达到控制执行模式注册顺序的目的
12+
/// </summary>
13+
[AttributeUsage(AttributeTargets.Method)]
14+
[MeansImplicitUse]
15+
public class CodeExecutorRegistrationAttribute : Attribute
16+
{
17+
18+
/// <summary>
19+
/// 执行顺序(该值越小则函数越先执行)
20+
/// </summary>
21+
public int order { get; }
22+
23+
/// <param name="order">执行顺序(该值越小则函数越先执行)</param>
24+
public CodeExecutorRegistrationAttribute(int order = 10)
25+
{
26+
this.order = order;
27+
}
28+
29+
/// <summary>
30+
/// 注册器
31+
/// </summary>
32+
[InitializeOnLoadMethod]
33+
private static void Registrar()
34+
{
35+
List<(MethodInfo method, int order)> list = new List<(MethodInfo method, int order)>();
36+
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
37+
{
38+
foreach (Type type in assembly.GetTypes())
39+
{
40+
foreach (MethodInfo method in type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public))
41+
{
42+
object[] attributes = method.GetCustomAttributes(typeof(CodeExecutorRegistrationAttribute), false);
43+
if (attributes.Length == 0)
44+
{
45+
continue;
46+
}
47+
CodeExecutorRegistrationAttribute attribute = attributes[0] as CodeExecutorRegistrationAttribute;
48+
list.Add((method, attribute!.order));
49+
}
50+
}
51+
}
52+
53+
list.Sort((a, b) => a.order - b.order);
54+
55+
foreach ((MethodInfo method, int order) item in list)
56+
{
57+
item.method.Invoke(null, null);
58+
}
59+
}
60+
61+
}
62+
63+
}

Editor/Scripts/Attributes/CodeExecutorRegistrationAttribute.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)