以下の内容はhttps://baba-s.hatenablog.com/entry/2022/02/22/090000より取得しました。


【Unity】ParticleSystem の Inspector に Play・Pause などのボタンを追加するエディタ拡張

ソースコード

using System;
using UnityEditor;
using UnityEngine;

[CustomEditor( typeof( ParticleSystem ) )]
public sealed class ParticleSystemInspector : Editor
{
    private static readonly Type BASE_EDITOR_TYPE = typeof( Editor )
        .Assembly
        .GetType( "UnityEditor.ParticleSystemInspector" );

    public override void OnInspectorGUI()
    {
        var particleSystem = ( ParticleSystem ) target;

        using ( new EditorGUILayout.HorizontalScope() )
        {
            if ( GUILayout.Button( "Play" ) )
            {
                particleSystem.Play();
            }

            if ( GUILayout.Button( "Stop" ) )
            {
                particleSystem.Stop();
            }

            if ( GUILayout.Button( "Pause" ) )
            {
                particleSystem.Pause();
            }

            if ( GUILayout.Button( "Clear" ) )
            {
                particleSystem.Clear();
            }
        }

        var editor = CreateEditor( particleSystem, BASE_EDITOR_TYPE );

        editor.OnInspectorGUI();
    }
}

使用例

f:id:baba_s:20220216184622p:plain




以上の内容はhttps://baba-s.hatenablog.com/entry/2022/02/22/090000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14