当前位置:网站首页>[note] usage model tree of the unity resource tree structure virtualizingtreeview
[note] usage model tree of the unity resource tree structure virtualizingtreeview
2022-06-30 05:08:00 【zjh_ three hundred and sixty-eight】
【 plug-in unit 】VirtualizingTreeView
Thanks for the plug-in source :Virtualizing Tree View - Self purchase scarcity Unity resources
The main function of this plug-in is to load local resources to generate UI Directory tree ,DOME The function in is to generate the following Hierarchy The panel is the same UI, Want to be a copy of the resource panel .

What I need this time is : Only the tree structure functions of the models in the project are displayed
One 、 In the project UI Add TreeView.prefab The precast body , At the same time, add an empty object and bind TreeViewDemo.cs Script
Two 、 Set the parent object of the model tree to be displayed Tag, Children do not need to be set , Then add judgment Tag Condition to display only the model tree
3、 ... and 、 add to Tag Judge the condition : stay TreeViewDemo.cs Script Start() Method, add a condition to the following code
IEnumerable<GameObject> dataItems = Resources.FindObjectsOfTypeAll<GameObject>().Where(go => !IsPrefab(go.transform) && go.transform.parent == null && go.tag == "Finish").OrderBy(t => t.transform.GetSiblingIndex());
Four 、 Click on the model tree object , Get the model : stay TreeViewDemo.cs Add the following code to the script
private void OnSelectionChanged(object sender, SelectionChangedArgs e)
{
#if UNITY_EDITOR
//Do something on selection changed (just syncronized with editor's hierarchy for demo purposes)
UnityEditor.Selection.objects = e.NewItems.OfType<GameObject>().ToArray();
#endif
// Get object
foreach (var item in e.NewItems.OfType<GameObject>().ToArray())
{
print(" In the test ..." + item.name);
print(item.gameObject.transform.localPosition);
}
// Get the last clicked object
foreach (var item in e.OldItems.OfType<GameObject>().ToArray())
{
print(item.gameObject);
}
}OnSelectionChanged This method was originally run under the editor , To show the synchronization effect , We should not write code to #if UNITY_EDITOR Just inside .
=========== The project is urgent , Other functions have not been studied in depth
边栏推荐
- 虚析构和纯虚析构
- Unity camera control
- 力扣292周赛题解
- Connect() and disconnect() of socket in C #
- Modbus protocol register
- Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor
- Output directory of log files after unity3d packaging
- 【VCS+Verdi聯合仿真】~ 以計數器為例
- Chapter 10 of OpenGL super classic (7th Edition) calculation shader
- Records of problems encountered in unity + hololens development
猜你喜欢

Malignant bug: 1252 of unit MySQL export

Unity + hololens common basic functions

Autowired注解警告的解决办法

HTC vive cosmos development - handle button event

Unity realizes rotation and Revolution

Unity automatic pathfinding

Photon pun refresh hall room list

Redis cluster concept

【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example

Win10 vs2015 compiling curaengine
随机推荐
Unity3d packaging and publishing APK process
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example
OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO
Deeply understand the function calling process of C language
Unity/ue reads OPC UA and OPC Da data (UE4)
Modbus protocol register
Introduction to some representations, neighbors and degrees of Graphs
C # equipment synthesis
redis集群概念
炒美原油的国际交易平台如何能保障资金安全呢?
【VCS+Verdi聯合仿真】~ 以計數器為例
Unity3d realizes Google Digital Earth
Li Kou 2049: count the number of nodes with the highest score
The difference between SVG and canvas
Records of problems encountered in unity + hololens development
Solution to the 292 week match of Li Kou
Draw on screen border in Commodore 64
Have a heart beating Valentine's day in Singapore
Unity realizes rotation and Revolution
Unity download and installation website