Files
daluandou/.codely.packages/cn.tuanjie.codely.bridge@1.0.85-785dea6a/Editor/Bridge/Helpers/ServerPathResolver.cs
T
huadexuan 53d95802e5 ```
feat(gameplay): 更新单位属性和材质配置

- 调整多个单位的基础生命值和攻击力数值平衡
- 修改CoreBattleGround材质的纹理缩放比例
- 更新地砖材质颜色为白色
- 优化纹理资源设置,调整最大纹理尺寸并添加PlayableAds平台支持
- 修复弓箭手技能目标查找逻辑,改用统一的敌人检测方法
- 为水晶矿添加中立阵营设置和光球视觉效果同步
- 调整预制体中的全局缩放参数
- 为狼人和石巨人添加NavMeshAgent组件支持
- 优化水晶矿血条显示位置计算方式
```
2026-09-20 21:52:31 +08:00

77 lines
2.6 KiB
C#

using System;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace UnityTcp.Editor.Helpers
{
public static class ServerPathResolver
{
/// <summary>
/// Attempts to locate the package root directory for cn.tuanjie.codely.bridge.
/// Returns true if found and sets packagePath to the package root folder.
/// </summary>
public static bool TryFindPackageRoot(out string packagePath, bool warnOnLegacyPackageId = true)
{
// Resolve via local package info (no network). Fall back to Client.List on older editors.
try
{
#if UNITY_2021_2_OR_NEWER
// Primary: the package that owns this assembly
var owner = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(ServerPathResolver).Assembly);
if (owner != null)
{
if (TryResolvePackage(owner, out packagePath, warnOnLegacyPackageId))
{
return true;
}
}
// Secondary: scan all registered packages locally
foreach (var p in UnityEditor.PackageManager.PackageInfo.GetAllRegisteredPackages())
{
if (TryResolvePackage(p, out packagePath, warnOnLegacyPackageId))
{
return true;
}
}
#else
// Older Unity versions: use Package Manager Client.List as a fallback
var list = UnityEditor.PackageManager.Client.List();
while (!list.IsCompleted) { }
if (list.Status == UnityEditor.PackageManager.StatusCode.Success)
{
foreach (var pkg in list.Result)
{
if (TryResolvePackage(pkg, out packagePath, warnOnLegacyPackageId))
{
return true;
}
}
}
#endif
}
catch { /* ignore */ }
packagePath = null;
return false;
}
private static bool TryResolvePackage(UnityEditor.PackageManager.PackageInfo p, out string packagePath, bool warnOnLegacyPackageId)
{
const string CurrentId = "cn.tuanjie.codely.bridge";
packagePath = null;
if (p == null || p.name != CurrentId)
{
return false;
}
packagePath = p.resolvedPath;
return !string.IsNullOrEmpty(packagePath) && Directory.Exists(packagePath);
}
}
}