MayHeCome/Assets/Editor/AttachGameObjectsToParticlesEditor.cs
2024-12-18 17:55:34 +08:00

32 lines
1009 B
C#

using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(AttachGameObjectsToParticles))]
public class AttachGameObjectsToParticlesEditor : Editor
{
public int Count = 0;
public int mode = 0;
public override void OnInspectorGUI()
{
// 通过 DrawDefaultInspector() 绘制原有的 Inspector 界面
DrawDefaultInspector();
// 获取目标脚本的引用
AttachGameObjectsToParticles script = (AttachGameObjectsToParticles)target;
// 添加 Count 滑块
Count = EditorGUILayout.IntSlider("Count", Count, 0, 1000000000);
// 添加 mode 的下拉菜单 (Left, Center, Right)
mode = EditorGUILayout.IntPopup("Mode", mode, new[] { "Left", "Center", "Right" }, new[] { -1, 0, 1 });
// 添加按钮,点击时调用 CreatParticle() 方法
if (GUILayout.Button("生成信仰粒子"))
{
// 根据 mode 生成对应位置的粒子
script.CreatCenterParticle(Count);
}
}
}