362 lines
16 KiB
C#
362 lines
16 KiB
C#
using System.IO;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
|
||
// 스킬 자체 제작 이펙트(2026-11-11 PD 「보유 이펙트로 어려우면 자체 제작하거나 조합·수정」) — 팩에 맞는 것이 없는 연출을 게임 그림체 그림으로 직접 만든다.
|
||
// TKS_Fx_C_ArrowRain = 화살비(손권): 반경 1 인 원 안으로 위에서 화살 24발이 떨어져 꽂힘(먼지 없음 · 2026-11-11 PD) · 크기 단위 = 광역 반경(표 blast f_scale 1 = 반경)
|
||
// TKS_Fx_C_SwordWave = 날아가는 초승달 검기(주태): 정면 = +X(표 b_flat 1 · b_face 1) · 머리 초승달 + 잔상 · 색 = 표 s_hue 로 바꿈(기본 주황)
|
||
// 그림 = Tools/make_skill_custom_textures.py(sk_arrow_down) · 초승달 = 기존 dash2d_crescent · 먼지 = dash2d_puff · 재질 = Sprites/Default
|
||
// 실행: unity command --project-path . --timeout 300 script eval --file Tools/build_skill_custom_fx.cs
|
||
string dir = "Assets/VFX/TKS2D/";
|
||
string fxDir = "Assets/Resources/Fx/";
|
||
AssetDatabase.Refresh();
|
||
{
|
||
var ti = (TextureImporter)AssetImporter.GetAtPath(dir + "sk_arrow_down.png");
|
||
ti.textureType = TextureImporterType.Sprite;
|
||
ti.spriteImportMode = SpriteImportMode.Single;
|
||
ti.mipmapEnabled = false;
|
||
ti.alphaIsTransparency = true;
|
||
ti.wrapMode = TextureWrapMode.Clamp;
|
||
ti.textureCompression = TextureImporterCompression.Uncompressed;
|
||
ti.SaveAndReimport();
|
||
}
|
||
Material Mat(string name, string tex)
|
||
{
|
||
var path = dir + "Mat_" + name + ".mat";
|
||
var m = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||
if (m == null)
|
||
{
|
||
m = new Material(Shader.Find("Sprites/Default"));
|
||
AssetDatabase.CreateAsset(m, path);
|
||
}
|
||
m.shader = Shader.Find("Sprites/Default");
|
||
m.mainTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(dir + tex + ".png");
|
||
EditorUtility.SetDirty(m);
|
||
return m;
|
||
}
|
||
ParticleSystem Ps(Transform parent, string name, Material mat)
|
||
{
|
||
var go = new GameObject(name);
|
||
go.transform.SetParent(parent, false);
|
||
var ps = go.AddComponent<ParticleSystem>();
|
||
ps.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
|
||
var r = go.GetComponent<ParticleSystemRenderer>();
|
||
r.sharedMaterial = mat;
|
||
r.renderMode = ParticleSystemRenderMode.Billboard;
|
||
r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||
r.receiveShadows = false;
|
||
var m = ps.main;
|
||
m.playOnAwake = true;
|
||
m.loop = false;
|
||
m.startSpeed = 0f;
|
||
m.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||
m.simulationSpace = ParticleSystemSimulationSpace.World;
|
||
var sh = ps.shape;
|
||
sh.enabled = false;
|
||
var em = ps.emission;
|
||
em.enabled = true;
|
||
em.rateOverTime = 0f;
|
||
return ps;
|
||
}
|
||
Gradient Fade(float a0, float hold)
|
||
{
|
||
var g = new Gradient();
|
||
g.SetKeys(new[] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) },
|
||
new[] { new GradientAlphaKey(a0, 0f), new GradientAlphaKey(a0, hold), new GradientAlphaKey(0f, 1f) });
|
||
return g;
|
||
}
|
||
var sb = new System.Text.StringBuilder();
|
||
var arrowMat = Mat("Sk_ArrowDown", "sk_arrow_down");
|
||
var crescentMat = Mat("Sk_Crescent", "dash2d_crescent");
|
||
|
||
// ── 화살비 ─────────────────────────────────────────────
|
||
{
|
||
var root = new GameObject("TKS_Fx_C_ArrowRain");
|
||
var arrows = Ps(root.transform, "Arrows", arrowMat);
|
||
var m = arrows.main;
|
||
m.duration = 0.7f;
|
||
m.startLifetime = 0.26f;
|
||
m.startSize3D = true;
|
||
m.startSizeX = 0.16f;
|
||
m.startSizeY = 0.56f;
|
||
m.startSizeZ = 1f;
|
||
m.maxParticles = 64;
|
||
var em = arrows.emission;
|
||
em.SetBursts(new[] { new ParticleSystem.Burst(0f, 6), new ParticleSystem.Burst(0.1f, 6), new ParticleSystem.Burst(0.2f, 6), new ParticleSystem.Burst(0.3f, 6) });
|
||
var sh = arrows.shape;
|
||
sh.enabled = true;
|
||
sh.shapeType = ParticleSystemShapeType.Circle;
|
||
sh.radius = 0.85f;
|
||
sh.radiusThickness = 1f;
|
||
sh.position = new Vector3(0.2f, 1.7f, 0f); // 떨어지기 시작하는 높이(반경 배수)
|
||
var vel = arrows.velocityOverLifetime;
|
||
vel.enabled = true;
|
||
vel.space = ParticleSystemSimulationSpace.Local;
|
||
vel.x = new ParticleSystem.MinMaxCurve(-0.2f / 0.26f);
|
||
vel.y = new ParticleSystem.MinMaxCurve(-1.7f / 0.26f);
|
||
vel.z = new ParticleSystem.MinMaxCurve(0f);
|
||
arrows.GetComponent<ParticleSystemRenderer>().pivot = new Vector3(0f, 0.5f, 0f); // 촉 끝이 입자 위치
|
||
|
||
var stuck = Ps(arrows.transform, "Stuck", arrowMat);
|
||
var sm = stuck.main;
|
||
sm.duration = 1f;
|
||
sm.startLifetime = 0.7f;
|
||
sm.startSize3D = true;
|
||
sm.startSizeX = 0.14f;
|
||
sm.startSizeY = 0.4f;
|
||
sm.startSizeZ = 1f;
|
||
sm.startRotation = new ParticleSystem.MinMaxCurve(-0.12f, 0.2f);
|
||
var se = stuck.emission;
|
||
se.SetBursts(new[] { new ParticleSystem.Burst(0f, 1) });
|
||
var sc = stuck.colorOverLifetime;
|
||
sc.enabled = true;
|
||
sc.color = Fade(1f, 0.7f);
|
||
stuck.GetComponent<ParticleSystemRenderer>().pivot = new Vector3(0f, 0.5f, 0f);
|
||
|
||
var sub = arrows.subEmitters;
|
||
sub.enabled = true;
|
||
sub.AddSubEmitter(stuck, ParticleSystemSubEmitterType.Death, ParticleSystemSubEmitterProperties.InheritNothing);
|
||
PrefabUtility.SaveAsPrefabAsset(root, fxDir + root.name + ".prefab");
|
||
Object.DestroyImmediate(root);
|
||
sb.AppendLine("TKS_Fx_C_ArrowRain");
|
||
}
|
||
|
||
// ── 초승달 검기 ─────────────────────────────────────────
|
||
{
|
||
var root = new GameObject("TKS_Fx_C_SwordWave");
|
||
var head = Ps(root.transform, "Head", crescentMat);
|
||
var m = head.main;
|
||
m.duration = 1f;
|
||
m.loop = true;
|
||
m.startLifetime = 0.09f;
|
||
m.startSize = 1f;
|
||
m.startColor = new Color(1f, 0.5f, 0.2f, 1f);
|
||
m.simulationSpace = ParticleSystemSimulationSpace.Local;
|
||
m.maxParticles = 16;
|
||
var em = head.emission;
|
||
em.rateOverTime = 45f;
|
||
head.GetComponent<ParticleSystemRenderer>().alignment = ParticleSystemRenderSpace.Local;
|
||
|
||
var trail = Ps(root.transform, "Trail", crescentMat);
|
||
var tm = trail.main;
|
||
tm.duration = 1f;
|
||
tm.loop = true;
|
||
tm.startLifetime = 0.16f;
|
||
tm.startSize = 0.8f;
|
||
tm.startColor = new Color(1f, 0.62f, 0.3f, 0.6f);
|
||
tm.maxParticles = 32;
|
||
var te = trail.emission;
|
||
te.rateOverTime = 14f;
|
||
var tc = trail.colorOverLifetime;
|
||
tc.enabled = true;
|
||
tc.color = Fade(1f, 0.1f);
|
||
var tz = trail.sizeOverLifetime;
|
||
tz.enabled = true;
|
||
tz.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.35f));
|
||
var tr = trail.GetComponent<ParticleSystemRenderer>();
|
||
tr.alignment = ParticleSystemRenderSpace.Local;
|
||
tr.sortingOrder = -1;
|
||
PrefabUtility.SaveAsPrefabAsset(root, fxDir + root.name + ".prefab");
|
||
Object.DestroyImmediate(root);
|
||
sb.AppendLine("TKS_Fx_C_SwordWave");
|
||
}
|
||
|
||
// ── 화살·비도 투사체 + 몸에 박힘(2026-11-11 PD 「투사체 크기가 비정상 · 화살이 그림 맨 위에 어색하게 → 입체적으로 박혀 있는 느낌」) ──
|
||
// 팩 FX_Shoot_Arrow/Dagger 는 3D 메시라 크기가 맞지 않고 꽂힌 화살이 머리 위에 길게 섬 → 게임 그림체 그림으로 직접 만듦 · 화풍 층을 거치지 않음(표 b_cel 0)
|
||
// TKS_Fx_C_ArrowShot · DaggerShot = 날아가는 화살·비도: 길이 1 단위(표 f_scale = 유닛 키 대비 길이) · 정면 +X(b_flat 1 · b_face 1) · 머리 + 흰 속도 줄기 + 가는 꼬리
|
||
// TKS_Fx_C_ArrowStuck · DaggerStuck = 몸에 박힌 화살·비도: 보이는 길이 1 단위 · 중심 = 박힌 자리 · SkillVfxStuck(파고듦 · 떨림 · 그림자 · 머문 뒤 흐려짐) + 타격 별 + 조각(먼지 없음)
|
||
Sprite ImportSprite(string name, float pivotX)
|
||
{
|
||
string path = dir + name + ".png";
|
||
var ti = (TextureImporter)AssetImporter.GetAtPath(path);
|
||
ti.textureType = TextureImporterType.Sprite;
|
||
ti.spriteImportMode = SpriteImportMode.Single;
|
||
ti.mipmapEnabled = true; // 화면에서 0.3~0.5 배로 줄어 그려짐 → 줄인 단계를 써서 움직일 때 깜빡이지 않게
|
||
ti.filterMode = FilterMode.Trilinear;
|
||
ti.alphaIsTransparency = true;
|
||
ti.wrapMode = TextureWrapMode.Clamp;
|
||
ti.textureCompression = TextureImporterCompression.Uncompressed;
|
||
int w, h;
|
||
ti.GetSourceTextureWidthAndHeight(out w, out h);
|
||
ti.spritePixelsPerUnit = w; // 그림 가로 = 1 단위
|
||
var st = new TextureImporterSettings();
|
||
ti.ReadTextureSettings(st);
|
||
st.spriteAlignment = (int)SpriteAlignment.Custom;
|
||
st.spritePivot = new Vector2(pivotX, 0.5f);
|
||
st.spriteMeshType = SpriteMeshType.FullRect;
|
||
ti.SetTextureSettings(st);
|
||
ti.SaveAndReimport();
|
||
return AssetDatabase.LoadAssetAtPath<Sprite>(path);
|
||
}
|
||
float Aspect(string name)
|
||
{
|
||
var t = AssetDatabase.LoadAssetAtPath<Texture2D>(dir + name + ".png");
|
||
return (float)t.height / t.width;
|
||
}
|
||
Material WhiteMat()
|
||
{
|
||
var path = dir + "Mat_Sk_White.mat";
|
||
var m = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||
if (m == null)
|
||
{
|
||
m = new Material(Shader.Find("Sprites/Default"));
|
||
AssetDatabase.CreateAsset(m, path);
|
||
}
|
||
return m;
|
||
}
|
||
void BuildShot(string prefabName, Material headMat, float aspect, Material streakMat, Material whiteMat)
|
||
{
|
||
var root = new GameObject(prefabName);
|
||
// 머리 = 짧은 수명 입자를 이어 냄(도착해 방출이 멈추면 0.06초 안에 사라짐 — 스프라이트면 지워질 때까지 도착점에 남음)
|
||
var head = Ps(root.transform, "Head", headMat);
|
||
var m = head.main;
|
||
m.duration = 1f;
|
||
m.loop = true;
|
||
m.prewarm = true;
|
||
m.startLifetime = 0.06f;
|
||
m.startSize3D = true;
|
||
m.startSizeX = 1f;
|
||
m.startSizeY = aspect;
|
||
m.startSizeZ = 1f;
|
||
m.simulationSpace = ParticleSystemSimulationSpace.Local;
|
||
m.maxParticles = 8;
|
||
var em = head.emission;
|
||
em.rateOverTime = 60f;
|
||
head.GetComponent<ParticleSystemRenderer>().alignment = ParticleSystemRenderSpace.Local;
|
||
|
||
var lines = Ps(root.transform, "Lines", streakMat);
|
||
var lm = lines.main;
|
||
lm.duration = 1f;
|
||
lm.loop = true;
|
||
lm.startLifetime = new ParticleSystem.MinMaxCurve(0.07f, 0.11f);
|
||
lm.startSize3D = true;
|
||
lm.startSizeX = new ParticleSystem.MinMaxCurve(0.5f, 0.9f);
|
||
lm.startSizeY = new ParticleSystem.MinMaxCurve(0.03f, 0.05f);
|
||
lm.startSizeZ = 1f;
|
||
lm.startColor = new Color(1f, 1f, 1f, 0.85f);
|
||
lm.simulationSpace = ParticleSystemSimulationSpace.Local;
|
||
lm.maxParticles = 16;
|
||
var le = lines.emission;
|
||
le.rateOverTime = 40f;
|
||
var ls = lines.shape;
|
||
ls.enabled = true;
|
||
ls.shapeType = ParticleSystemShapeType.Box;
|
||
ls.scale = new Vector3(0.4f, 0.34f, 0f);
|
||
ls.position = new Vector3(-0.75f, 0f, 0f);
|
||
var lv = lines.velocityOverLifetime;
|
||
lv.enabled = true;
|
||
lv.space = ParticleSystemSimulationSpace.Local;
|
||
lv.x = new ParticleSystem.MinMaxCurve(-2.5f);
|
||
lv.y = new ParticleSystem.MinMaxCurve(0f);
|
||
lv.z = new ParticleSystem.MinMaxCurve(0f);
|
||
var lc = lines.colorOverLifetime;
|
||
lc.enabled = true;
|
||
lc.color = Fade(1f, 0.3f);
|
||
lines.GetComponent<ParticleSystemRenderer>().alignment = ParticleSystemRenderSpace.Local;
|
||
|
||
var tgo = new GameObject("Trail");
|
||
tgo.transform.SetParent(root.transform, false);
|
||
tgo.transform.localPosition = new Vector3(-0.3f, 0f, 0f);
|
||
var tr = tgo.AddComponent<TrailRenderer>();
|
||
tr.sharedMaterial = whiteMat;
|
||
tr.time = 0.07f;
|
||
tr.widthCurve = AnimationCurve.Linear(0f, 0.1f, 1f, 0f);
|
||
var g = new Gradient();
|
||
g.SetKeys(new[] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) },
|
||
new[] { new GradientAlphaKey(0.6f, 0f), new GradientAlphaKey(0f, 1f) });
|
||
tr.colorGradient = g;
|
||
tr.minVertexDistance = 0.05f;
|
||
tr.numCapVertices = 2;
|
||
tr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||
tr.receiveShadows = false;
|
||
PrefabUtility.SaveAsPrefabAsset(root, fxDir + root.name + ".prefab");
|
||
Object.DestroyImmediate(root);
|
||
sb.AppendLine(prefabName);
|
||
}
|
||
void BuildStuck(string prefabName, Sprite sprite, Material popMat, Material chipMat, int chips)
|
||
{
|
||
var root = new GameObject(prefabName);
|
||
var pivot = new GameObject("Pivot").transform;
|
||
pivot.SetParent(root.transform, false);
|
||
var sh = new GameObject("Shadow");
|
||
sh.transform.SetParent(pivot, false);
|
||
sh.transform.localPosition = new Vector3(0f, 0f, 0.01f); // 같은 순서 안에서 대보다 뒤
|
||
var ssr = sh.AddComponent<SpriteRenderer>();
|
||
ssr.sprite = sprite;
|
||
ssr.color = new Color(0.118f, 0.086f, 0.063f, 0.32f);
|
||
var body = new GameObject("Body");
|
||
body.transform.SetParent(pivot, false);
|
||
body.AddComponent<SpriteRenderer>().sprite = sprite;
|
||
var stuck = root.AddComponent<TKS.SkillVfxStuck>();
|
||
stuck.pivot = pivot;
|
||
stuck.shadow = sh.transform;
|
||
|
||
var pop = Ps(root.transform, "Pop", popMat);
|
||
pop.transform.localPosition = new Vector3(0f, 0f, -0.01f);
|
||
var pm = pop.main;
|
||
pm.duration = 0.5f;
|
||
pm.startLifetime = 0.15f;
|
||
pm.startSize = 0.95f;
|
||
pm.startRotation = new ParticleSystem.MinMaxCurve(-0.5f, 0.5f);
|
||
pm.simulationSpace = ParticleSystemSimulationSpace.Local;
|
||
var pe = pop.emission;
|
||
pe.SetBursts(new[] { new ParticleSystem.Burst(0f, 1) });
|
||
var pc = pop.colorOverLifetime;
|
||
pc.enabled = true;
|
||
pc.color = Fade(1f, 0.55f);
|
||
var pz = pop.sizeOverLifetime;
|
||
pz.enabled = true;
|
||
pz.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0.45f, 1f, 1.1f));
|
||
|
||
// 조각 = 날아온 쪽(−X)으로 부채꼴로 튐(먼지는 2026-11-11 PD 「스킬 공격에 피격 시 먼지 발생되는 이펙트는 제거」로 뺌)
|
||
var chip = Ps(root.transform, "Chips", chipMat);
|
||
var cm = chip.main;
|
||
cm.duration = 0.5f;
|
||
cm.startLifetime = new ParticleSystem.MinMaxCurve(0.28f, 0.42f);
|
||
cm.startSpeed = new ParticleSystem.MinMaxCurve(2f, 3.6f);
|
||
cm.startSize3D = true;
|
||
cm.startSizeX = new ParticleSystem.MinMaxCurve(0.2f, 0.28f);
|
||
cm.startSizeY = new ParticleSystem.MinMaxCurve(0.11f, 0.16f);
|
||
cm.startSizeZ = 1f;
|
||
cm.startRotation = new ParticleSystem.MinMaxCurve(0f, 6.28f);
|
||
cm.gravityModifier = 1.2f;
|
||
var ce = chip.emission;
|
||
ce.SetBursts(new[] { new ParticleSystem.Burst(0f, (short)chips) });
|
||
var cs = chip.shape;
|
||
cs.enabled = true;
|
||
cs.shapeType = ParticleSystemShapeType.Circle;
|
||
cs.radius = 0.05f;
|
||
cs.arc = 110f;
|
||
cs.rotation = new Vector3(0f, 0f, 125f);
|
||
var cr = chip.rotationOverLifetime;
|
||
cr.enabled = true;
|
||
cr.z = new ParticleSystem.MinMaxCurve(-8f, 8f);
|
||
var cc = chip.colorOverLifetime;
|
||
cc.enabled = true;
|
||
cc.color = Fade(1f, 0.6f);
|
||
|
||
PrefabUtility.SaveAsPrefabAsset(root, fxDir + root.name + ".prefab");
|
||
Object.DestroyImmediate(root);
|
||
sb.AppendLine(prefabName);
|
||
}
|
||
{
|
||
ImportSprite("sk_arrow", 0.5f);
|
||
ImportSprite("sk_dagger", 0.5f);
|
||
ImportSprite("sk_hit_pop", 0.5f);
|
||
ImportSprite("sk_streak", 0.5f);
|
||
ImportSprite("sk_chip", 0.5f);
|
||
var arrowStuck = ImportSprite("sk_arrow_stuck", 0.875f); // 중심 = 박힌 자리(그림 112 / 128)
|
||
var daggerStuck = ImportSprite("sk_dagger_stuck", 0.846f); // 88 / 104
|
||
var white = WhiteMat();
|
||
var streakMat = Mat("Sk_Streak", "sk_streak");
|
||
var popMat = Mat("Sk_HitPop", "sk_hit_pop");
|
||
var chipMat = Mat("Sk_Chip", "sk_chip");
|
||
BuildShot("TKS_Fx_C_ArrowShot", Mat("Sk_Arrow", "sk_arrow"), Aspect("sk_arrow"), streakMat, white);
|
||
BuildShot("TKS_Fx_C_DaggerShot", Mat("Sk_Dagger", "sk_dagger"), Aspect("sk_dagger"), streakMat, white);
|
||
BuildStuck("TKS_Fx_C_ArrowStuck", arrowStuck, popMat, chipMat, 4);
|
||
BuildStuck("TKS_Fx_C_DaggerStuck", daggerStuck, popMat, chipMat, 2);
|
||
}
|
||
AssetDatabase.SaveAssets();
|
||
AssetDatabase.Refresh();
|
||
return sb.ToString();
|