I learned from the online prompts, but I forgot to save the specific website, so I cannot store it here!If you need to specify the source, contact me.
PS: I did not elaborate on the details on the Internet. I made some code implementation and sorted it out.
Next I will use the uitable component instead of uigrid to sort items.
Make the item into a preset body, such as 3: questlog (this go corresponds to questlog in the official example)
Mount the script on the go Object questlog In the preset questlogprefab. For example, in step 1: Name the script questlogprefab (of course, the same class name is used), and then declare the go object in the script that needs to dynamically change data, remember to make public (visible in the editor), such as mtitle label and mcount label in the above figure (corresponding to the variables in the following scripts respectively)
After the program is started, the above mtitle label, mcount label, and so on will be initialized before start () (because it has been bound in the editor)
After loading the preset body, obtain the variables in the script based on the corresponding class name questlogprefab (the benefit is that you do not need to use gameobject. Find () to find go !!!) :
Then, see questlog in 2 (A gameobject)
The class includes two public member variables: mtestuitablego (the parent object questlog of the preset body item) and mtestuitable. In the script
BTW, dynamic deletion, You can first use the remove item method in uitable (the name is missing -_-!), Then use destroy to destroy the loaded and preset body items (PS: if your application often dynamically creates and deletes items, it is best to create a recycle pool: reset the pre-body before removing it, save it to the List, and take it in the list if needed. If the list is empty, load the pre-body item .)
PS: I did not proofread the text when I typed it. If there are errors or other problems to be improved, please point them out. Thank you very much!
End: reprinted. Please specify the source!
Ngui scrollview dynamically add item (you do not need gameobject. Find () to find game objects that need to be dynamically changed)