79 lines
3.5 KiB
C#
79 lines
3.5 KiB
C#
using UnityEditor;
|
||
using UnityEngine;
|
||
|
||
// 빛 번짐 원판(자체 제작 · 2026-11-13 PD 「원판 그림을 만들어서 보여줘」 · 방통 봉추의 계 터짐 뒤의 큰 흰 원판 = 원본 미리보기 영상의 빛 번짐)
|
||
// TKS_Fx_C_GlowDisk = 원판(Disk · 크기 1) + 바깥 빛(Halo · 크기 1.4 · 옅게) · 0.12초에 커지며 나타나 0.55초 뒤 흐려짐 · 한 번 재생
|
||
// 그림 = Tools/make_glow_disk_texture.py(Assets/VFX/TKS2D/sk_glow_disk.png) · 재질 = Sprites/Default(보통 섞기 = 모래 바탕에서도 흰색이 날아가지 않음)
|
||
// 크기 단위 = 원판 지름(표 f_scale × 유닛 키 · 행의 size 1)
|
||
// 실행: unity command --project-path . --timeout 300 script eval --file Tools/build_glow_disk.cs
|
||
string dir = "Assets/VFX/TKS2D/";
|
||
string texPath = dir + "sk_glow_disk.png";
|
||
AssetDatabase.Refresh();
|
||
var ti = (TextureImporter)AssetImporter.GetAtPath(texPath);
|
||
if (ti == null) return "그림 없음: " + texPath;
|
||
ti.textureType = TextureImporterType.Sprite;
|
||
ti.spriteImportMode = SpriteImportMode.Single;
|
||
ti.mipmapEnabled = false;
|
||
ti.alphaIsTransparency = true;
|
||
ti.wrapMode = TextureWrapMode.Clamp;
|
||
ti.textureCompression = TextureImporterCompression.Uncompressed;
|
||
ti.SaveAndReimport();
|
||
|
||
string matPath = dir + "Mat_sk_glow_disk.mat";
|
||
var mat = AssetDatabase.LoadAssetAtPath<Material>(matPath);
|
||
if (mat == null)
|
||
{
|
||
mat = new Material(Shader.Find("Sprites/Default"));
|
||
AssetDatabase.CreateAsset(mat, matPath);
|
||
}
|
||
mat.shader = Shader.Find("Sprites/Default");
|
||
mat.mainTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(texPath);
|
||
EditorUtility.SetDirty(mat);
|
||
|
||
ParticleSystem Layer(Transform parent, string name, float size, float alpha, int order)
|
||
{
|
||
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 = false;
|
||
m.playOnAwake = true;
|
||
m.startLifetime = 0.7f;
|
||
m.startSpeed = 0f;
|
||
m.startSize = size;
|
||
m.startColor = new Color(1f, 1f, 1f, alpha);
|
||
m.simulationSpace = ParticleSystemSimulationSpace.Local;
|
||
m.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||
m.maxParticles = 2;
|
||
var em = ps.emission;
|
||
em.rateOverTime = 0f;
|
||
em.SetBursts(new[] { new ParticleSystem.Burst(0f, 1) });
|
||
var sh = ps.shape;
|
||
sh.enabled = false;
|
||
var sz = ps.sizeOverLifetime;
|
||
sz.enabled = true;
|
||
sz.size = new ParticleSystem.MinMaxCurve(1f, new AnimationCurve(new Keyframe(0f, 0.55f), new Keyframe(0.17f, 1f), new Keyframe(1f, 1.08f)));
|
||
var col = ps.colorOverLifetime;
|
||
col.enabled = true;
|
||
var g = new Gradient();
|
||
g.SetKeys(new[] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) },
|
||
new[] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 0.1f), new GradientAlphaKey(1f, 0.6f), new GradientAlphaKey(0f, 1f) });
|
||
col.color = new ParticleSystem.MinMaxGradient(g);
|
||
var r = go.GetComponent<ParticleSystemRenderer>();
|
||
r.sharedMaterial = mat;
|
||
r.renderMode = ParticleSystemRenderMode.Billboard;
|
||
r.sortingOrder = order;
|
||
return ps;
|
||
}
|
||
|
||
var root = new GameObject("TKS_Fx_C_GlowDisk");
|
||
Layer(root.transform, "Halo", 1.4f, 0.45f, -1);
|
||
Layer(root.transform, "Disk", 1f, 1f, 0);
|
||
string outPath = "Assets/Resources/Fx/TKS_Fx_C_GlowDisk.prefab";
|
||
PrefabUtility.SaveAsPrefabAsset(root, outPath);
|
||
Object.DestroyImmediate(root);
|
||
AssetDatabase.SaveAssets();
|
||
return "TKS_Fx_C_GlowDisk ← " + texPath;
|