当前位置:网站首页>Extensions de l'éditeur d'unityeditor - fonctions de table
Extensions de l'éditeur d'unityeditor - fonctions de table
2022-06-26 22:45:00 【Avi9111】
Table des matières
UnityEditorMots clés du tableau
Parce qu'il faut compter le nombre de champs de bataille,NPC,Et la fonction du bâtiment
Je l'ai découvert.,Comme si je n'avais jamais fait de contrôle de table avant(Trop loin,Je ne l'ai pas trouvé.)
La première fois,Internet Baidu,Il s'avère qu'il a aussi trouvé des informations sur un frère,Et son code open source
UnityEditorMots clés du tableau
Scrope,TreeView
Enfin, tu sais,UnityIl doit y avoir des contrôles à l'intérieur de l'administration,C'est juste que ce n'est pas public
Le petit frère a dit:J'espère aussi.unityRendre public dès que possible
Mais en faitunityEn tant que société cotée,Le but est deunrealLa compétition est le moteur+De l'éditeur,Toute la compagnie est toujours en train de faire“”Diverses mises à jour“,Ce n'est pas du tout dans les détails personnalisés de ces programmeurs(imgui + c# mono La couche est déjà très avancée , Tellement en avance qu'il est impossible de dépasser ) Prenez soin de , Les mises à jour officielles n'ont même pas besoin d'y penser
Editor La clé de l'extension de l'éditeur est toujours d'utiliser internal Composants de
SerializedPropertyTable
Et
SerializedPropertyTreeView.Column[]
Petit frère exemple 1:
ListeCameras
m_table = new SerializedPropertyTable("Table", FindObjects, CreateCameraColumn);// Trouver la caméra ( Bon exemple. ) private Camera[] FindObjects()
{
return FindObjectsOfType<Camera>();
} private SerializedPropertyTreeView.Column[] CreateCameraColumn(out string[] propnames)
{
propnames = new string[3];
var columns = new SerializedPropertyTreeView.Column[3];
columns[0] = new SerializedPropertyTreeView.Column
{
headerContent = new GUIContent("Name"),
headerTextAlignment = TextAlignment.Left,
sortedAscending = true,
sortingArrowAlignment = TextAlignment.Center,
width = 200,
minWidth = 25f,
maxWidth = 400,
autoResize = false,
allowToggleVisibility = true,
propertyName = null,
dependencyIndices = null,
compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareName,
drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawName,
filter = new SerializedPropertyFilters.Name()
};
columns[1] = new SerializedPropertyTreeView.Column
{
headerContent = new GUIContent("On"),
headerTextAlignment = TextAlignment.Left,
sortedAscending = true,
sortingArrowAlignment = TextAlignment.Center,
width = 25,
autoResize = false,
allowToggleVisibility = true,
propertyName = "m_Enabled",
dependencyIndices = null,
compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareCheckbox,
drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawCheckbox,
};
columns[2] = new SerializedPropertyTreeView.Column
{
headerContent = new GUIContent("Mask"),
headerTextAlignment = TextAlignment.Left,
sortedAscending = true,
sortingArrowAlignment = TextAlignment.Center,
width = 200,
minWidth = 25f,
maxWidth = 400,
autoResize = false,
allowToggleVisibility = true,
propertyName = "m_CullingMask",
dependencyIndices = null,
compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareInt,
drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault,
filter = new SerializedPropertyFilters.Name()
};
for (var i = 0; i < columns.Length; i++)
{
var column = columns[i];
propnames[i] = column.propertyName;
}
return columns;
}C'est ça.,onguiÇa doit être écrit.(Touttable Le noyau de structure est toujours basé sur onguiSystème, Si vous avez déjà écrit OnGUI()J'ai compris.)
using (new EditorGUILayout.VerticalScope())
{
m_table.OnGUI();
}
Petit frère exemple 2:
Extension de la liste de données personnalisées ,
Bien que l'exemple 1 soit bon , Mais l'extensibilité n'est pas , Presque inutile , Et c'est juste la preuve que les données sont vraiment réalisables Binder,Même siEditor Toutes les liaisons internes ,MaisBinder Propriétés des champs correspondants ,Par exemple:Name,m_EnableAttendez un peu!, Il est difficile d'identifier le bon nom ( Il faut réessayer )
Donc voici l'exemple 2 , Une couche en plus de la classe de données personnalisée
Définir sa propre classe
La méthode 1 ci - dessus , Seules les méthodes internes sont prises en charge (Unity.Object), Le petit frère a emballé une autre couche d'écriture , Prise en charge des types de données personnalisés
//Méthodes2
public class ExampleDataTable : CommonTable<GameRunTimeItem>
{
public ExampleDataTable(List<GameRunTimeItem> datas,
CommonTableColumn<GameRunTimeItem>[] cs,
FilterMethod<GameRunTimeItem> onfilter,
SelectMethod<GameRunTimeItem> onselect = null)
: base(datas, cs, onfilter, onselect)
{
}
} public class GameRunTimeItem
{
public string Name;
public int Count;
public int ID;
public int Age;
}Enrobage Column
void InitTableData(bool forceUpdate = false)
{
if (forceUpdate || m_table == null)
{
//init datas
var datas = new List<GameRunTimeItem>();
//for example,add some test datas
datas.Add(new GameRunTimeItem() { ID = 101, Age = 10, Name = "Lili" });
datas.Add(new GameRunTimeItem() { ID = 203, Age = 15, Name = "JoJo" });
datas.Add(new GameRunTimeItem() { ID = 404, Age = 11, Name = "Kikki" });
datas.Add(new GameRunTimeItem() { ID = 508, Age = 30, Name = "Baby" });
//init columns
var cols = new CommonTableColumn<GameRunTimeItem>[]
{
new CommonTableColumn<GameRunTimeItem>
{
headerContent = new GUIContent("ID"), //header display name
canSort = true, //
Compare = (a,b)=>-a.ID.CompareTo(b.ID), //sort method
DrawCell = (rect,data)=>EditorGUI.LabelField(rect,data.ID.ToString()),
},
new CommonTableColumn<GameRunTimeItem>
{
headerContent = new GUIContent("Name"),//header display name
canSort = true,
Compare = (a,b)=>-a.Name.CompareTo(b.Name),//sort method
DrawCell = (rect,data)=>EditorGUI.LabelField(rect,data.Name),
},
new CommonTableColumn<GameRunTimeItem>
{
headerContent = new GUIContent("Age"),//header display name
DrawCell = (rect,data)=>EditorGUI.LabelField(rect,data.Age.ToString()),
}
};
m_table = new ExampleDataTable(datas, cols, OnTableFilter, OnRowSelect);
}
}
/// <summary>
///
/// </summary>
/// <param name="datas"></param>
private void OnRowSelect(List<GameRunTimeItem> datas)
{
throw new NotImplementedException();
}
private bool OnTableFilter(GameRunTimeItem data, string std)
{
int number;
if (!int.TryParse(std, out number))
return false;
return data.ID == number;
} using (new EditorGUILayout.VerticalScope())
{
if (m_table == null)
InitTableData();
if (m_table != null)
m_table.OnGUI();
}
Capture d'écran finale

边栏推荐
- [kotlin] keyword suspend learning of thread operation and async understanding
- VB. Net class library - 4 screen shots, clipping
- Homebrew installation in MacOS environment [email protected]
- Unity布料系統_Cloth組件(包含動態調用相關)
- 分享三種在Excel錶格中自動求和的方法
- 不花一分钱做个在线的gif合成服务
- Installation avec homebrew dans un environnement Mac OS [email protected]
- [bug feedback] the problem of message sending time of webim online chat system
- Introduction to operator
- MacOS環境下使用HomeBrew安裝[email protected]
猜你喜欢

leetcode:152. 乘积最大子数组【考虑两个维度的dp】

Data governance does everything
![leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】](/img/a4/c5c31de7a0a3b34a188bfec0b5d184.png)
leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】

CVPR 2022 - Interpretation of selected papers of meituan technical team
![leetcode:141. Circular linked list [hash table + speed pointer]](/img/19/f918f2cff9f831d4bbc411fe1b9776.png)
leetcode:141. Circular linked list [hash table + speed pointer]

Pass note 【 dynamic planning 】

在Flutter中解析复杂的JSON

FPGA -vga display
![leetcode:152. Product maximum subarray [consider DP of two dimensions]](/img/c8/af6a4c969affd151a5214723dffb57.png)
leetcode:152. Product maximum subarray [consider DP of two dimensions]
![[machine learning] - Introduction to vernacular and explanation of terms](/img/4c/e18fe52a71444c2ca08167ead9f28f.jpg)
[machine learning] - Introduction to vernacular and explanation of terms
随机推荐
LabVIEW Arduino tcp/ip remote smart home system (project part-5)
WP collection plug-in tutorial no thanks for WordPress collection of rules
Vulnhub's DC8
大龄程序员的一些出路
Which platform is the safest for buying stocks and opening accounts? Ask for sharing
LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)
简析攻防演练中蓝队的自查内容
Introduction to operator
Open world mecha games phantom Galaxy
Unity3d plug-in anyportrait 2D bone animation
【BUG反馈】WebIM在线聊天系统发消息时间问题
vulnhub之dc8
Unity animation knowledge of Art
尚硅谷DolphinScheduler视频教程发布
Some ways out for older programmers
买股票通过中金证券经理的开户二维码开户资金是否安全?想开户炒股
vulnhub之DC9
Fastadmin Aurora push send message registration_ Multiple IDs are invalid after being separated by commas
【混合编程jni 】第七篇之JNI 的命令行们
nmap参数详解