116 lines
6.4 KiB
C#
116 lines
6.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
// WL837 — ExplosiveLLC Warrior 데모 씬 구동 준비 (가산만 · 기존 항목 변경 없음)
|
|
// ① InputManager: 팩 Input Presets 중 프로젝트에 없는 축 11개 추가 (값 = Assets/ExplosiveLLC/Warrior/Presets/Input Presets.preset 그대로)
|
|
// ② TagManager: SuperCharacterController 가 이름으로 찾는 레이어 "TempCast" 를 빈 슬롯(13 이상 첫 빈칸)에 추가
|
|
// 실행: unity command run_script --file AgentScripts/WL837_DemoSceneSetup.cs --entry WL837_DemoSceneSetup.Run --args '[false]' (점검)
|
|
// unity command run_script --file AgentScripts/WL837_DemoSceneSetup.cs --entry WL837_DemoSceneSetup.Run --args '[true]' (적용)
|
|
public static class WL837_DemoSceneSetup
|
|
{
|
|
struct Axis { public string name, pos, altPos; public float gravity, dead, sens; public int snap, type, axis; }
|
|
static Axis A(string name, string pos, float gravity, float dead, float sens, int snap, int type, int axis, string altPos = "")
|
|
=> new Axis { name = name, pos = pos, altPos = altPos, gravity = gravity, dead = dead, sens = sens, snap = snap, type = type, axis = axis };
|
|
|
|
// 프로젝트에 이미 있는 Horizontal·Vertical·Jump·Mouse * 는 제외. type 0 = Key/Mouse Button · 2 = Joystick Axis
|
|
static readonly Axis[] Needed =
|
|
{
|
|
A("BlockTarget", "", 1000, 0.001f, 1, 1, 2, 2),
|
|
A("Target", "left shift", 1000, 0.001f, 1, 0, 0, 2),
|
|
A("Attack", "joystick button 2", 1000, 0.001f, 1000, 0, 0, 0),
|
|
A("AttackMove", "joystick button 3", 1000, 0.001f, 1000, 0, 0, 0),
|
|
A("AttackRanged", "joystick button 0", 1000, 0.001f, 1000, 0, 0, 0),
|
|
A("AttackSpecial", "joystick button 1", 1000, 0.001f, 1000, 0, 0, 0),
|
|
A("Aiming", "", 1, 0.001f, 1, 0, 0, 2),
|
|
A("AimHorizontal", "", 1, 0.001f, 1, 0, 2, 2),
|
|
A("AimVertical", "", 1, 0.001f, 1, 0, 2, 2),
|
|
A("Death", "joystick button 4", 1, 0.001f, 1, 0, 0, 0),
|
|
A("LightHit", "joystick button 5", 1, 0.001f, 1, 0, 0, 0),
|
|
};
|
|
const string TempLayer = "TempCast";
|
|
const int FirstFreeLayerIndex = 13;
|
|
|
|
static void SetFlag(SerializedProperty p, int v)
|
|
{
|
|
if (p.propertyType == SerializedPropertyType.Boolean) p.boolValue = v != 0; else p.intValue = v;
|
|
}
|
|
|
|
public static string Run(bool apply)
|
|
{
|
|
if (EditorApplication.isPlaying) return "skipped: editor is playing (PD Play 중 쓰기 금지)";
|
|
var sb = new StringBuilder();
|
|
|
|
// ① InputManager
|
|
var im = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
|
|
var so = new SerializedObject(im);
|
|
var axes = so.FindProperty("m_Axes");
|
|
var have = new HashSet<string>();
|
|
for (int i = 0; i < axes.arraySize; i++) have.Add(axes.GetArrayElementAtIndex(i).FindPropertyRelative("m_Name").stringValue);
|
|
int before = axes.arraySize, added = 0;
|
|
foreach (var a in Needed)
|
|
{
|
|
if (have.Contains(a.name)) { sb.Append("axis ").Append(a.name).Append(": exists\n"); continue; }
|
|
if (apply)
|
|
{
|
|
axes.arraySize++;
|
|
var el = axes.GetArrayElementAtIndex(axes.arraySize - 1);
|
|
el.FindPropertyRelative("m_Name").stringValue = a.name;
|
|
el.FindPropertyRelative("descriptiveName").stringValue = "";
|
|
el.FindPropertyRelative("descriptiveNegativeName").stringValue = "";
|
|
el.FindPropertyRelative("negativeButton").stringValue = "";
|
|
el.FindPropertyRelative("positiveButton").stringValue = a.pos;
|
|
el.FindPropertyRelative("altNegativeButton").stringValue = "";
|
|
el.FindPropertyRelative("altPositiveButton").stringValue = a.altPos;
|
|
el.FindPropertyRelative("gravity").floatValue = a.gravity;
|
|
el.FindPropertyRelative("dead").floatValue = a.dead;
|
|
el.FindPropertyRelative("sensitivity").floatValue = a.sens;
|
|
SetFlag(el.FindPropertyRelative("snap"), a.snap);
|
|
SetFlag(el.FindPropertyRelative("invert"), 0);
|
|
el.FindPropertyRelative("type").intValue = a.type;
|
|
el.FindPropertyRelative("axis").intValue = a.axis;
|
|
el.FindPropertyRelative("joyNum").intValue = 0;
|
|
}
|
|
added++;
|
|
sb.Append("axis ").Append(a.name).Append(apply ? ": added\n" : ": missing\n");
|
|
}
|
|
if (apply && added > 0) so.ApplyModifiedPropertiesWithoutUndo();
|
|
sb.Append("axes: ").Append(before).Append(" -> ").Append(apply ? before + added : before).Append('\n');
|
|
|
|
// ② TagManager layer
|
|
var tm = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0];
|
|
var tso = new SerializedObject(tm);
|
|
var layers = tso.FindProperty("layers");
|
|
int idx = -1, free = -1;
|
|
for (int i = 0; i < layers.arraySize; i++)
|
|
{
|
|
var v = layers.GetArrayElementAtIndex(i).stringValue;
|
|
if (v == TempLayer) idx = i;
|
|
else if (free < 0 && i >= FirstFreeLayerIndex && string.IsNullOrEmpty(v)) free = i;
|
|
}
|
|
if (idx >= 0) sb.Append("layer ").Append(TempLayer).Append(": exists @").Append(idx).Append('\n');
|
|
else if (apply && free >= 0)
|
|
{
|
|
layers.GetArrayElementAtIndex(free).stringValue = TempLayer;
|
|
tso.ApplyModifiedPropertiesWithoutUndo();
|
|
sb.Append("layer ").Append(TempLayer).Append(": added @").Append(free).Append('\n');
|
|
}
|
|
else sb.Append("layer ").Append(TempLayer).Append(": missing (free slot ").Append(free).Append(")\n");
|
|
|
|
if (apply) AssetDatabase.SaveAssets();
|
|
|
|
// 실측 확인: 레이어 이름 해석 + 축 존재(없으면 ArgumentException)
|
|
sb.Append("NameToLayer(").Append(TempLayer).Append(") = ").Append(LayerMask.NameToLayer(TempLayer)).Append('\n');
|
|
int ok = 0, err = 0;
|
|
foreach (var a in Needed)
|
|
{
|
|
try { Input.GetAxisRaw(a.name); ok++; }
|
|
catch (Exception e) { err++; sb.Append("input ").Append(a.name).Append(": ERR ").Append(e.Message).Append('\n'); }
|
|
}
|
|
sb.Append("input check ok=").Append(ok).Append(" err=").Append(err).Append('\n');
|
|
return sb.ToString();
|
|
}
|
|
}
|