当前位置:网站首页>[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 enables simple music visualization
- Tcp/ip protocol details Volume I (Reading Guide)
- Have a heart beating Valentine's day in Singapore
- Brew install NVM command not found solution
- Unity application class and data file path
- Unity dotween plug-in description
- 很紧张,第一天做软件测试,需要做什么?
- Force buckle 349 Intersection of two arrays
- Ripple effect of mouse click (unity & shader)
- Unreal 4 learning notes - set player birth point
猜你喜欢

Unreal 4 unavigationsystemv1 compilation error

Redis cluster concept

Oculus quest2 development: (I) basic environment construction and guide package

Writing unityshader with sublimetext

Unity3d packaging and publishing APK process

Photon pun refresh hall room list

Unity project hosting platform plasticscm (learn to use 2)

Force buckle 209 Minimum length subarray

QT connecting external libraries

Force buckle 977 Square of ordered array
随机推荐
redis集群概念
Solution to Autowired annotation warning
Database base (Study & review for self use)
C # equipment synthesis
Chinese pycharm changed to English pycharm
LxC and LXD container summary
Malignant bug: 1252 of unit MySQL export
Read and save txt files
Pytorchcnn image recognition and classification model training framework
Redis cluster concept
Autowired注解警告的解决办法
Unity lens making
Force buckle 349 Intersection of two arrays
C # Foundation
Tensorflow2 of ubantu18.04 X installation
UnityEngine. JsonUtility. The pit of fromjason()
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example
Nestjs中控制器和路由的配置使用
力扣292周赛题解
Nestjs configures static resources, template engine, and post examples