当前位置:网站首页>unity编辑器扩展界面使用 List
unity编辑器扩展界面使用 List
2022-08-10 00:41:00 【王源骏】
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()
{
//修改视频逻辑
}
}
参考资料
https://blog.csdn.net/w_mumu_q/article/details/107240127
https://blog.csdn.net/puppet_master/article/details/51012298
https://blog.csdn.net/qq_35361471/article/details/84713382
边栏推荐
- DHCP——动态主机配置协议
- R语言使用coxph函数构建生存分析回归模型,使用forestmodel包的forest_model函数可视化生存回归模型对应的森林图
- egg.js中Class constructor BaseContextClass cannot be invoked without ‘new‘解决方法
- Solidity 智能合约入门
- eyb:Redis学习(4)
- shell指定参数名传参
- 2022金九银十工作潮,怎么样才能成功跳槽面试拿到高薪呢?
- R语言使用glm函数构建逻辑回归模型(logistic)、使用subgroupAnalysis函数进行亚组分析并可视化森林图
- C语言头文件组织与包含原则
- c语言文件基本操作总结
猜你喜欢
鲜花线上销售管理系统的设计与实现
DHCP——动态主机配置协议
Solidity最强对手:MOVE语言及新公链崛起
FITC标记生物素(FITC-生物素|CAS:134759-22-1)有哪些知识了?
ITK编译remote库
PEG derivative Biotin-PEG1-OH (cas: 95611-10-2, 2-biotinaminoethanol) advantage description
【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式
C language pointer practice questions
02| operator
Quick responsiveness intelligent/smart responsiveness of polyethylene glycol type nano/reduction response hydrogels research and preparation
随机推荐
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG衍生物
Sikuli 基于图形识别的自动化测试技术
Summary of basic operations of c language files
Biotin-Cy2 Conjugate,生物素-Cy2 偶联物_Cy2 生物素偶联物
生物素叠氮化物中的(CAS:1527486-16-3TAMRA-azide-PEG3-Biotin)反应的特点!
-Vector Dot Product-
R语言使用glm函数构建logistic回归模型,使用forestmodel包的forest_model函数可视化逻辑回归模型对应的森林图
Moonbeam网络维护模式(Maintenance Mode)解读
02|运算符
R语言使用cox函数构建生存分析回归模型、使用subgroupAnalysis进行亚组分析并可视化森林图
【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格
微信小程序tab切换时保存checkbox状态
宝塔实测-搭建LightPicture开源图床系统
pyhton之问~~~~~if __name__ == ‘__main__‘:是什么?
R语言使用glm函数构建逻辑回归模型(logistic)、使用subgroupAnalysis函数进行亚组分析并可视化森林图
【无标题】
【kali-密码攻击】(5.1.2)密码在线破解:Medusa
CAS:851113-28-5 (Biotin-ahx-ahx-tyramine)
你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06
鲜花线上销售管理系统的设计与实现