GFramework/GFramework.Godot/Extensions/GodotPathExtensions.cs
GeWuYou fb14d7122c docs(style): 更新文档中的命名空间导入格式
- 将所有小写的命名空间导入更正为首字母大写格式
- 统一 GFramework 框架的命名空间引用规范
- 修复 core、ecs、godot 等模块的命名空间导入错误
- 标准化文档示例代码中的 using 语句格式
- 确保所有文档中的命名空间引用保持一致性
- 更新 global using 语句以匹配正确的命名空间格式
2026-03-10 07:18:49 +08:00

38 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace GFramework.Godot.Extensions;
/// <summary>
/// 提供对 Godot 路径相关操作的扩展方法。
/// 包含判断路径类型的功能例如用户数据路径user://和资源路径res://)。
/// </summary>
public static class GodotPathExtensions
{
/// <summary>
/// 判断指定路径是否为 Godot 用户数据路径user://)。
/// </summary>
/// <param name="path">待检查的路径字符串。</param>
/// <returns>如果路径以 "user://" 开头且不为空,则返回 true否则返回 false。</returns>
public static bool IsUserPath(this string path)
{
return !string.IsNullOrEmpty(path) && path.StartsWith("user://");
}
/// <summary>
/// 判断指定路径是否为 Godot 资源路径res://)。
/// </summary>
/// <param name="path">待检查的路径字符串。</param>
/// <returns>如果路径以 "res://" 开头且不为空,则返回 true否则返回 false。</returns>
public static bool IsResPath(this string path)
{
return !string.IsNullOrEmpty(path) && path.StartsWith("res://");
}
/// <summary>
/// 判断指定路径是否为 Godot 特殊路径user:// 或 res://)。
/// </summary>
/// <param name="path">待检查的路径字符串。</param>
/// <returns>如果路径是用户数据路径或资源路径,则返回 true否则返回 false。</returns>
public static bool IsGodotPath(this string path)
{
return path.IsUserPath() || path.IsResPath();
}
}