条件:不能放在Editor下,需要挂载到物体身上。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class TestGame : MonoBehaviour
{
private void OnGUI()
{
if( GUILayout.Button("test1", GUILayout.Width(100)))
{
Debug.Log("test1");
}
}
}