using LitJson;
using System;
using UnityEditor;
using UnityEngine;

///<summary>播放音频</summary>
public class PlayAudioOperateEditor : IOperateEditor
{
    public string Name => "播放音频";

    public Type Component => typeof(PlayAudioComponent);

    private PlayAudioData Data;

    public void Init(string json)
    {
        Data = string.IsNullOrEmpty(json) ? new PlayAudioData() : JsonMapper.ToObject<PlayAudioData>(json);
    }

    public void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("音频名称:", GUILayout.Width(55));
        Data.AudioName = EditorGUILayout.TextField(Data.AudioName);
        EditorGUILayout.EndHorizontal();
    }

    public string ToData()
    {
        return JsonMapper.ToJson(Data);
    }

    public void Dispose()
    {
    }
}