60 lines
3.6 KiB
C#
60 lines
3.6 KiB
C#
|
|
// WL839_ChargeVisuals.cs — 활 3타 「기 모으기」·「강화 화살 글로우」 시각 프리팹 생성 (#839 · PD 「활에 기가 모이는 임팩트 후 좀 더 큰 화살」)
|
||
|
|
// unity command run_script --file AgentScripts/WL839_ChargeVisuals.cs --entry WL839_ChargeVisuals.Build
|
||
|
|
// 원본(Hovl Studio RPG VFX Bundle · 프로젝트 안 에셋)을 인스턴스로 풀어 파티클·렌더러만 남긴 WL 프리팹 2종을 만든다(원본 0줄):
|
||
|
|
// Magic Sparks → Assets/WL/Combat/Weapon/Resources/WL/WL_BowChargeVisual.prefab (활 소켓에 0.45 s · 크기 0.4)
|
||
|
|
// Gold dot → Assets/WL/Combat/Weapon/Resources/WL/WL_ArrowChargeVisual.prefab (강화 화살 자식 · 크기 0.5)
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using UnityEditor;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public static class WL839_ChargeVisuals
|
||
|
|
{
|
||
|
|
const string SrcDir = "Assets/ResWork/VFX/Hovl Studio/RPG VFX Bundle/Prefabs/Magic buffs and hits/";
|
||
|
|
const string DstDir = "Assets/WL/Combat/Weapon/Resources/WL/";
|
||
|
|
|
||
|
|
public static object Build()
|
||
|
|
{
|
||
|
|
if (EditorApplication.isPlaying) return "skipped: playing";
|
||
|
|
var sb = new StringBuilder();
|
||
|
|
sb.Append(Clone(SrcDir + "Magic Sparks.prefab", DstDir + "WL_BowChargeVisual.prefab", "WL_BowChargeVisual", 0.4f, true)).Append('\n');
|
||
|
|
sb.Append(Clone(SrcDir + "Gold dot.prefab", DstDir + "WL_ArrowChargeVisual.prefab", "WL_ArrowChargeVisual", 0.5f, true));
|
||
|
|
AssetDatabase.SaveAssets();
|
||
|
|
return sb.ToString();
|
||
|
|
}
|
||
|
|
|
||
|
|
static string Clone(string srcPath, string dstPath, string name, float scale, bool loop)
|
||
|
|
{
|
||
|
|
var src = AssetDatabase.LoadAssetAtPath<GameObject>(srcPath);
|
||
|
|
if (src == null) return "원본 없음 " + srcPath;
|
||
|
|
var inst = (GameObject)PrefabUtility.InstantiatePrefab(src);
|
||
|
|
try
|
||
|
|
{
|
||
|
|
PrefabUtility.UnpackPrefabInstance(inst, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
|
||
|
|
inst.name = name;
|
||
|
|
inst.transform.position = Vector3.zero; inst.transform.rotation = Quaternion.identity; inst.transform.localScale = Vector3.one * scale;
|
||
|
|
int removed = 0;
|
||
|
|
for (int pass = 0; pass < 6; pass++)
|
||
|
|
{
|
||
|
|
var comps = inst.GetComponents<Component>().Where(c => c != null && !(c is Transform)).ToArray();
|
||
|
|
if (comps.Length == 0) break;
|
||
|
|
foreach (var c in comps.OrderBy(c => c is Rigidbody ? 2 : (c is Collider ? 1 : 0)))
|
||
|
|
{
|
||
|
|
if (c is ParticleSystem || c is ParticleSystemRenderer) continue;
|
||
|
|
try { Object.DestroyImmediate(c); removed++; } catch (System.Exception) { }
|
||
|
|
}
|
||
|
|
if (inst.GetComponents<Component>().All(c => c is Transform || c is ParticleSystem || c is ParticleSystemRenderer)) break;
|
||
|
|
}
|
||
|
|
foreach (var col in inst.GetComponentsInChildren<Collider>(true)) { Object.DestroyImmediate(col); removed++; }
|
||
|
|
foreach (var mb in inst.GetComponentsInChildren<MonoBehaviour>(true)) { if (mb != null) { Object.DestroyImmediate(mb); removed++; } }
|
||
|
|
foreach (var l in inst.GetComponentsInChildren<Light>(true)) { Object.DestroyImmediate(l); removed++; }
|
||
|
|
int ps = 0;
|
||
|
|
foreach (var p in inst.GetComponentsInChildren<ParticleSystem>(true)) { var m = p.main; m.playOnAwake = true; m.loop = loop; ps++; }
|
||
|
|
PrefabUtility.SaveAsPrefabAsset(inst, dstPath);
|
||
|
|
AssetDatabase.ImportAsset(dstPath);
|
||
|
|
return "저장 " + dstPath + " · 제거 " + removed + " · 파티클 " + ps + " · 크기 " + scale;
|
||
|
|
}
|
||
|
|
finally { Object.DestroyImmediate(inst); }
|
||
|
|
}
|
||
|
|
}
|