using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

//这个节点必须在现实的下边
public class checkRootFirstRun : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        utilsTools.addTimer_Update(gameObject, "tempcheck", (string name) =>
        {
            //loopCheck(transform);
            return false;
        });
    }
    private void loopCheck(Transform trans)
    {
        Vector3 vectorCenter = new Vector3(0, 0);
        Quaternion quaterion = new Quaternion();
        for (int i = 0;i < trans.childCount; i++)
        {
            var obj = trans.GetChild(i).gameObject;
            if (obj.active == false)
            {
                Vector3 pos1 = new Vector3();
                obj.transform.GetPositionAndRotation(out pos1, out quaterion);
                utilsTools.setUserData(obj, "initPos__temp", pos1);
                obj.transform.SetPositionAndRotation(new Vector3(-1000, -1000), quaterion);
                obj.SetActive(true);
                utilsTools.addTimer_Update(gameObject, "initPosTempTime", (string name) =>
                {
                    utilsTools.getUserData<Vector3>(obj, "initPos__temp", out pos1, vectorCenter);
                    obj.transform.SetPositionAndRotation(pos1, quaterion);
                    obj.SetActive(false);
                    return false;
                }, 5);
            }
            loopCheck(obj.transform);
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
