129 lines
5.0 KiB
C#
129 lines
5.0 KiB
C#
|
|
using UnityEditor;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
// 육손 불 장벽 바닥 프리팹(2026-11-19 PD 「바닥에 어두운 (그을림 및 타는 발화원)이 없어서 어색 · 자연스럽게」)
|
||
|
|
// TKS_Fx_C_FireBed = 그을린 바닥(Scorch · 가로로 넓은 얼룩) → 타는 숯 덩이(Coals · 은은히 밝기가 오르내림) → 깜박이며 살짝 오르는 불씨(Embers) — 뒤에서 앞 순서(sortingFudge)
|
||
|
|
// 그림 = Tools/make_firebed_textures.py → Assets/VFX/TKS2D/sk_scorch · sk_coals · sk_ember · 크기 단위 1(표 size 1) · 모든 층 반복(지대 = 원래 반복인 층만 남김) ·
|
||
|
|
// 그을음·숯 = 입자 1개를 오래 유지(지대가 끝나면 부모와 함께 지워짐).
|
||
|
|
// 실행: python -I -X utf8 Tools/make_firebed_textures.py . → unity command --project-path . --timeout 300 script eval --file Tools/build_firebed.cs
|
||
|
|
string dir = "Assets/VFX/TKS2D/";
|
||
|
|
string dst = "Assets/Resources/Fx/TKS_Fx_C_FireBed.prefab";
|
||
|
|
AssetDatabase.Refresh();
|
||
|
|
|
||
|
|
Material Mat(string tex)
|
||
|
|
{
|
||
|
|
var ti = AssetImporter.GetAtPath(dir + tex + ".png") as TextureImporter;
|
||
|
|
if (ti != null)
|
||
|
|
{
|
||
|
|
ti.textureType = TextureImporterType.Default;
|
||
|
|
ti.alphaIsTransparency = true;
|
||
|
|
ti.wrapMode = TextureWrapMode.Clamp;
|
||
|
|
ti.mipmapEnabled = true;
|
||
|
|
ti.textureCompression = TextureImporterCompression.Uncompressed;
|
||
|
|
ti.SaveAndReimport();
|
||
|
|
}
|
||
|
|
var path = dir + "Mat_" + tex + ".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 Layer(Transform parent, string name, Material mat, float fudge)
|
||
|
|
{
|
||
|
|
var go = new GameObject(name);
|
||
|
|
go.transform.SetParent(parent, false);
|
||
|
|
var ps = go.AddComponent<ParticleSystem>();
|
||
|
|
ps.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
|
||
|
|
var m = ps.main;
|
||
|
|
m.duration = 1f;
|
||
|
|
m.loop = true;
|
||
|
|
m.playOnAwake = true;
|
||
|
|
m.startSpeed = 0f;
|
||
|
|
m.gravityModifier = 0f;
|
||
|
|
m.simulationSpace = ParticleSystemSimulationSpace.Local;
|
||
|
|
m.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||
|
|
var sh = ps.shape;
|
||
|
|
sh.enabled = false;
|
||
|
|
var r = go.GetComponent<ParticleSystemRenderer>();
|
||
|
|
r.sharedMaterial = mat;
|
||
|
|
r.renderMode = ParticleSystemRenderMode.Billboard;
|
||
|
|
r.sortingFudge = fudge;
|
||
|
|
r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||
|
|
r.receiveShadows = false;
|
||
|
|
return ps;
|
||
|
|
}
|
||
|
|
|
||
|
|
void Persist(ParticleSystem ps, float sx, float sy)
|
||
|
|
{
|
||
|
|
var m = ps.main;
|
||
|
|
m.startLifetime = 1000f;
|
||
|
|
m.maxParticles = 1;
|
||
|
|
m.startSize3D = true;
|
||
|
|
m.startSizeX = sx;
|
||
|
|
m.startSizeY = sy;
|
||
|
|
m.startSizeZ = 1f;
|
||
|
|
var em = ps.emission;
|
||
|
|
em.rateOverTime = 1f;
|
||
|
|
em.SetBursts(new[] { new ParticleSystem.Burst(0f, 1) });
|
||
|
|
}
|
||
|
|
|
||
|
|
Gradient G(Color a, Color b, Color c, float a0, float a1, float a2)
|
||
|
|
{
|
||
|
|
var g = new Gradient();
|
||
|
|
g.SetKeys(new[] { new GradientColorKey(a, 0f), new GradientColorKey(b, 0.5f), new GradientColorKey(c, 1f) },
|
||
|
|
new[] { new GradientAlphaKey(a0, 0f), new GradientAlphaKey(a1, 0.35f), new GradientAlphaKey(a2, 1f) });
|
||
|
|
return g;
|
||
|
|
}
|
||
|
|
|
||
|
|
void Alpha(ParticleSystem ps, float a)
|
||
|
|
{
|
||
|
|
var m = ps.main;
|
||
|
|
m.startColor = new Color(1f, 1f, 1f, a);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 2026-11-20 PD 「육손의 불기둥 및 그을음이 너무 진한 느낌 · 조금만 약하게」 → 그을음 불투명도 1 → 0.55 · 숯 1 → 0.8
|
||
|
|
float SCORCH_A = 0.55f, COAL_A = 0.8f;
|
||
|
|
var root = new GameObject("TKS_Fx_C_FireBed");
|
||
|
|
var scorch = Layer(root.transform, "Scorch", Mat("sk_scorch"), 20f);
|
||
|
|
Persist(scorch, 1f, 0.72f);
|
||
|
|
Alpha(scorch, SCORCH_A);
|
||
|
|
|
||
|
|
var coals = Layer(root.transform, "Coals", Mat("sk_coals"), 10f);
|
||
|
|
Persist(coals, 0.92f, 0.62f); // 1차 0.62 = 불기둥에 가려 안 보임(캡처) → 기둥 양옆으로 드러나게
|
||
|
|
Alpha(coals, COAL_A);
|
||
|
|
coals.transform.localPosition = new Vector3(0f, -0.02f, 0f);
|
||
|
|
|
||
|
|
var embers = Layer(root.transform, "Embers", Mat("sk_ember"), 0f);
|
||
|
|
var em2 = embers.main;
|
||
|
|
em2.startLifetime = new ParticleSystem.MinMaxCurve(0.45f, 0.9f);
|
||
|
|
em2.startSize = new ParticleSystem.MinMaxCurve(0.05f, 0.11f);
|
||
|
|
em2.maxParticles = 24;
|
||
|
|
var ee = embers.emission;
|
||
|
|
ee.rateOverTime = 12f;
|
||
|
|
var es = embers.shape;
|
||
|
|
es.enabled = true;
|
||
|
|
es.shapeType = ParticleSystemShapeType.Circle;
|
||
|
|
es.radius = 0.24f;
|
||
|
|
es.rotation = Vector3.zero;
|
||
|
|
es.scale = new Vector3(1f, 0.6f, 1f);
|
||
|
|
var ev = embers.velocityOverLifetime;
|
||
|
|
ev.enabled = true;
|
||
|
|
ev.space = ParticleSystemSimulationSpace.Local;
|
||
|
|
ev.x = new ParticleSystem.MinMaxCurve(-0.05f, 0.05f);
|
||
|
|
ev.y = new ParticleSystem.MinMaxCurve(0.08f, 0.32f);
|
||
|
|
ev.z = new ParticleSystem.MinMaxCurve(0f, 0f);
|
||
|
|
var ec = embers.colorOverLifetime;
|
||
|
|
ec.enabled = true;
|
||
|
|
ec.color = new ParticleSystem.MinMaxGradient(G(Color.white, new Color(1f, 0.85f, 0.6f), new Color(0.9f, 0.35f, 0.15f), 0f, 1f, 0f));
|
||
|
|
PrefabUtility.SaveAsPrefabAsset(root, dst);
|
||
|
|
Object.DestroyImmediate(root);
|
||
|
|
AssetDatabase.SaveAssets();
|
||
|
|
return "ok " + dst;
|