43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BITKit;
|
|
using UnityEngine;
|
|
|
|
namespace Net.Project.B.WorldNode
|
|
{
|
|
public class UnityEnvironmentController : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject[] staticGameObjects;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if(Application.isEditor)return;
|
|
foreach (var staticGameObject in staticGameObjects)
|
|
{
|
|
staticGameObject.isStatic = true;
|
|
}
|
|
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
|
|
Destroy(this);
|
|
}
|
|
private void Start()
|
|
{
|
|
foreach (var staticGameObject in staticGameObjects)
|
|
{
|
|
staticGameObject.isStatic = true;
|
|
}
|
|
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
|
|
}
|
|
|
|
[ContextMenu("Build Index")]
|
|
public void Rebuild()
|
|
{
|
|
staticGameObjects = GetComponentsInChildren<Transform>().Where(x=>x.gameObject.isStatic).Select(x=>x.gameObject).ToArray();
|
|
Debug.Log($"已获取到{staticGameObjects.Length}个物体");
|
|
}
|
|
}
|
|
|
|
}
|
|
|