using System;using System.Collections;using System.Collections.Generic;using UnityEditor;using UnityEngine;[CustomEditor(typeof(TeachTool))]public class TeachTool : EditorWindow{[MenuItem("ConfigTool/添加图片或者视频")]public static void ConfigTool(){//创建面板EditorWindow.GetWindow(typeof(TeachTool));}public UnityEngine.Object setting;[SerializeField]public List<Sprite> spriteLiset=new List<Sprite>();//图片的List//序列化对象protected SerializedObject _serializedObject;protected SerializedObject _serializedObject2;//序列化属性protected SerializedProperty _assetLstProperty;protected SerializedProperty _assetLstProperty2;[SerializeField]public List<UnityEngine.Object> MediaLiset = new List<UnityEngine.Object>();public string tempFiled = "";private void OnEnable(){}private void OnGUI(){GUILayout.Label("面板", EditorStyles.boldLabel);//配置文件 这个可以忽略 因为我写的这个工具是修改自己工程内配置文件的setting = EditorGUILayout.ObjectField(setting, typeof(TeachPointSetting), true);//输入框tempFiled = EditorGUILayout.TextField("名字:", tempFiled);//设置间距EditorGUILayout.Space(20);//初始化_serializedObject = new SerializedObject(this);//获取当前类中可序列化的属性_assetLstProperty = _serializedObject.FindProperty("spriteLiset");//更新_serializedObject.Update();//开始检查是否有修改EditorGUI.BeginChangeCheck();//显示属性,第二个参数必须为true 否者无法显示子节点即List内容EditorGUILayout.PropertyField(_assetLstProperty, true);//结束检查是否有修改if (EditorGUI.EndChangeCheck()){_serializedObject.ApplyModifiedProperties();}//设置间距EditorGUILayout.Space(10);//添加按钮if(GUILayout.Button("确认添加图片")){SetSprsite();}//设置间距EditorGUILayout.Space(20);_serializedObject2 = new SerializedObject(this);_assetLstProperty2 = _serializedObject2.FindProperty("MediaLiset");//更新_serializedObject2.Update();//开始检查是否有修改EditorGUI.BeginChangeCheck();//显示属性,第二个参数必须为true 否者无法显示子节点即List内容EditorGUILayout.PropertyField(_assetLstProperty2, true);//结束检查是否有修改if (EditorGUI.EndChangeCheck()){_serializedObject2.ApplyModifiedProperties();}//设置间距EditorGUILayout.Space(10);//添加按钮if (GUILayout.Button("确认添加视频")){SetMedia();}}/// <summary>/// 修改图片/// </summary>public void SetSprsite(){//修改图片逻辑}public void SetMedia(){//修改视频逻辑}}
参考资料
/w_mumu_q/article/details/107240127
/puppet_master/article/details/51012298
/qq_35361471/article/details/84713382