Skip to content

Commit

Permalink
Merge pull request #87 from AIO-GAME/1.x
Browse files Browse the repository at this point in the history
1.x
  • Loading branch information
xinansky authored Jun 6, 2024
2 parents 8faa7cf + 313085d commit 299efae
Show file tree
Hide file tree
Showing 19 changed files with 474 additions and 258 deletions.
17 changes: 7 additions & 10 deletions Editor.GUI.CLI/External/AIO.Git/MenuItem.Git.ALL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ internal static partial class PackageGen
{
private static IEnumerable<PackageInfo> GetInfo()
{
var packageInfos = AssetDatabase.FindAssets("package", new[] { "Packages" })
.Select(AssetDatabase.GUIDToAssetPath)
.Where(x => AssetDatabase.LoadAssetAtPath<TextAsset>(x) != null)
.Select(PackageInfo.FindForAssetPath)
.GroupBy(x => x.assetPath)
.Select(x => x.First())
.Where(x => File.Exists(Path.Combine(x.resolvedPath, ".git"))
|| Directory.Exists(Path.Combine(x.resolvedPath, ".git")))
.ToList();
return packageInfos;
return AssetDatabase.FindAssets("package", new[] { "Packages" })
.Select(AssetDatabase.GUIDToAssetPath)
.Where(x => AssetDatabase.LoadAssetAtPath<TextAsset>(x) != null)
.Select(PackageInfo.FindForAssetPath)
.GroupBy(x => x.assetPath)
.Select(x => x.First())
.Where(x => AHelper.IO.Exists(Path.Combine(x.resolvedPath, ".git")));
}

#region Git All
Expand Down
36 changes: 13 additions & 23 deletions Editor.GUI.CLI/External/AIO.Git/MenuItem.Git.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,36 @@ internal static partial class PackageGen
/// <summary>
/// 生成
/// </summary>
[MenuItem("Git/~~~ Generate ~~~", false, 9999)]
[MenuItem("Git/[ Generate Code ->", false, 9999)]
internal static void Generate()
{
Debug.Log($"<b><color=#5DADE2>[GIT]</color></b> {CMD_GIT} Generate");

var packageInfos = AssetDatabase.FindAssets("package", new[] { "Packages" })
.Select(AssetDatabase.GUIDToAssetPath)
.Where(x => AssetDatabase.LoadAssetAtPath<TextAsset>(x) != null)
.Select(PackageInfo.FindForAssetPath)
.GroupBy(x => x.assetPath)
.Select(x => x.First())
.Where(x =>
File.Exists(Path.Combine(EHelper.Path.Project, x.resolvedPath, ".git")) ||
Directory.Exists(Path.Combine(EHelper.Path.Project, x.resolvedPath, ".git"))
)
.ToList();

var change = CreateProject();
if (CreateTemplate(packageInfos)) change = true;
var change = CreateProject() || CreateTemplate
(AssetDatabase.FindAssets("package", new[] { "Packages" })
.Select(AssetDatabase.GUIDToAssetPath)
.Where(x => AssetDatabase.LoadAssetAtPath<TextAsset>(x) != null)
.Select(PackageInfo.FindForAssetPath)
.GroupBy(x => x.assetPath)
.Select(x => x.First())
.Where(x => AHelper.IO.Exists(Path.Combine(EHelper.Path.Project, x.resolvedPath, ".git"))));
if (!change) return;

AssetDatabase.Refresh();
var RefreshSettings =
typeof(AssetDatabase).GetMethod("RefreshSettings", BindingFlags.Static | BindingFlags.Public);
var RefreshSettings = typeof(AssetDatabase).GetMethod("RefreshSettings", BindingFlags.Static | BindingFlags.Public);
if (RefreshSettings != null) RefreshSettings.Invoke(null, null);
CompilationPipeline.RequestScriptCompilation();
}

[AInit(EInitAttrMode.Editor, ushort.MaxValue - 1)]
internal static void AutoGenerate()
{
if (EHelper.Prefs.LoadBoolean("Git.AutoGenerate"))
Generate();
if (EHelper.Prefs.LoadBoolean("Git.AutoGenerate")) Generate();
}

/// <summary>
/// 生成
/// </summary>
[MenuItem("Git/~~~ Clean ~~~", false, 9999)]
[MenuItem("Git/[ Clear Code ->", false, 9999)]
internal static void Clean()
{
var OutPath = GetOutPath();
Expand All @@ -76,8 +67,7 @@ internal static void Clean()
AssetDatabase.RefreshSettings();
#endif

var RefreshSettings = typeof(AssetDatabase).GetMethod("RefreshSettings",
BindingFlags.Static | BindingFlags.Public);
var RefreshSettings = typeof(AssetDatabase).GetMethod("RefreshSettings", BindingFlags.Static | BindingFlags.Public);
if (RefreshSettings != null) RefreshSettings.Invoke(null, null);

CompilationPipeline.RequestScriptCompilation();
Expand Down
50 changes: 26 additions & 24 deletions Runtime/Tools/Initialize/AInitAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
#region

using System;
#if UNITY_EDITOR
using System.Runtime.CompilerServices;
#endif

#endregion

namespace AIO.UEditor
{
/// <summary>
/// 初始化属性
/// </summary>
/// <c>使用方式</c>
/// <code>
/// [AInit(EInitAttrMode.Editor)] : 编辑器启动
/// [AInit(EInitAttrMode.RuntimeAfterAssembliesLoaded)] : 程序集加载
/// [AInit(0)] : 优先级
/// </code>
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public class AInitAttribute : Attribute
{
public AInitAttribute(int order = 0
#if UNITY_EDITOR
,
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = 0
#endif
)
public string FilePath { get; }
public int LineNumber { get; }

public AInitAttribute(int order = 0, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
{
#if UNITY_EDITOR
FilePath = filePath.Replace("\\", "/");
LineNumber = lineNumber;
#endif
Order = order;
Order = order;
}

public AInitAttribute(EInitAttrMode mode,
int order = 0
#if UNITY_EDITOR
,
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = 0
#endif
)
public AInitAttribute(EInitAttrMode mode, int order = 0, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
{
#if UNITY_EDITOR
FilePath = filePath.Replace("\\", "/");
LineNumber = lineNumber + 1;
#endif
Mode = mode;
Mode = mode;
Order = order;
}
#else
public AInitAttribute(int order = 0) { Order = order; }
public AInitAttribute(EInitAttrMode mode, int order = 0)
{
Mode = mode;
Order = order;
}
#endif

public EInitAttrMode Mode { get; set; } = EInitAttrMode.Editor;

public int Order { get; set; }
#if UNITY_EDITOR
public string FilePath { get; }
public int LineNumber { get; }
#endif
}
}
Loading

0 comments on commit 299efae

Please sign in to comment.