47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class wuniusj : MonoBehaviour
|
|
{
|
|
Transform[] allChildren;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Transform[] allChildren = GetComponentsInChildren<Transform>();
|
|
}
|
|
public void yingchang()
|
|
{
|
|
|
|
// 遍历并打印每个子物体的名称
|
|
foreach (Transform child in allChildren)
|
|
{
|
|
if (child != transform) // 排除当前物体本身
|
|
{
|
|
child.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
public void show()
|
|
{
|
|
yingchang();
|
|
// 遍历并打印每个子物体的名称
|
|
foreach (Transform child in allChildren)
|
|
{
|
|
if (child != transform) // 排除当前物体本身
|
|
{
|
|
if (Random.Range(0,10) > 5)
|
|
{
|
|
child.gameObject.SetActive(true);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|