单向平台
This commit is contained in:
@@ -95,7 +95,9 @@ namespace BaseGames.Editor
|
||||
Transform groundCheckT = GetOrCreateChild(root.transform, "GroundCheck");
|
||||
groundCheckT.localPosition = new Vector3(0f, -0.75f, 0f);
|
||||
AssignReference(playerMovement, "_groundCheck", groundCheckT, report);
|
||||
AssignLayerMask(playerMovement, "_groundLayer", "Platform", report);
|
||||
AssignLayerMask(playerMovement, "_groundLayer",
|
||||
new[] { "Platform", "OneWayPlatform", "MovingOneWayPlatform", "MidHeightOneWayPlatform" },
|
||||
report);
|
||||
|
||||
// ── SkillHitBox_Slot 子节点(技能 HitBox 实例化挂点)────────────────
|
||||
Transform skillSocketT = GetOrCreateChild(root.transform, "SkillHitBox_Slot");
|
||||
@@ -1001,6 +1003,31 @@ namespace BaseGames.Editor
|
||||
so.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
/// <summary>将多个 Layer 名称合并为一个 LayerMask 并写入 SerializedProperty。</summary>
|
||||
private static void AssignLayerMask(Object target, string propName, string[] layerNames, List<string> report)
|
||||
{
|
||||
int mask = 0;
|
||||
foreach (var name in layerNames)
|
||||
{
|
||||
int layer = LayerMask.NameToLayer(name);
|
||||
if (layer == -1)
|
||||
report.Add($"Layer '{name}' 不存在,已跳过({target.GetType().Name}.{propName})。");
|
||||
else
|
||||
mask |= 1 << layer;
|
||||
}
|
||||
if (mask == 0) return;
|
||||
|
||||
var so = new SerializedObject(target);
|
||||
var sp = so.FindProperty(propName);
|
||||
if (sp == null)
|
||||
{
|
||||
report.Add($"{target.GetType().Name}.{propName} 字段不存在,跳过 LayerMask 赋值。");
|
||||
return;
|
||||
}
|
||||
sp.intValue = mask;
|
||||
so.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
private static void AssignInt(Object target, string propName, int value)
|
||||
{
|
||||
var so = new SerializedObject(target);
|
||||
|
||||
Reference in New Issue
Block a user