SetChildSibilingIndex.cs 450 B

123456789101112131415161718192021
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. namespace Rokid.UXR.Demo
  5. {
  6. public class SetChildSibilingIndex : MonoBehaviour
  7. {
  8. [SerializeField]
  9. private Text text;
  10. void Start()
  11. {
  12. if (text == null)
  13. {
  14. text = GetComponentInChildren<Text>();
  15. }
  16. if (text != null)
  17. text.text = transform.GetSiblingIndex() + "";
  18. }
  19. }
  20. }