ar_tourism_flutter_unity/unity/VRProject2/Assets/zhl/zhlScripts/OtherUserMannger.cs
2025-05-14 17:04:13 +08:00

35 lines
826 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OtherUserMannger : MonoBehaviour
{
public int count;
public GameObject otherUser;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(transform.childCount > count)
{
for(int i = transform.childCount - 1; i >= count; i--)
{
Destroy(transform.GetChild(i).gameObject);
}
}
else if(transform.childCount < count)
{
for(int i = transform.childCount; i < count; i++)
{
GameObject user = Instantiate(otherUser);
user.transform.parent = transform;
}
}
}
}