using System.Collections; using System.Collections.Generic; using UnityEngine; using System; namespace BF { public class DreamlandInstancingHelper : MonoBehaviour { Action luaUpdateAction; MaterialPropertyBlock block; MeshFilter meshFilter; List materixList = new List(); List lightmapOffsetList = new List(); void Awake() { block = new MaterialPropertyBlock(); } public void SetLuaUpdateAction(Action updateAction) { luaUpdateAction = updateAction; } public void ClearLuaUpdateAction() { luaUpdateAction = null; } public MaterialPropertyBlock GetMaterialPorpertyBlock() { return block; } public MeshFilter GetMeshFilter() { meshFilter = GetComponentInChildren(); return meshFilter; } public Vector4[] CollectLightmapOffsetArray() { lightmapOffsetList.Clear(); var meshRenderers = GetComponentsInChildren(); foreach (var mr in meshRenderers) { lightmapOffsetList.Add(mr.lightmapScaleOffset); } return lightmapOffsetList.ToArray(); } public List CollectMaterixList() { materixList.Clear(); var meshRenderers = GetComponentsInChildren(); foreach (var mr in meshRenderers) { materixList.Add(mr.localToWorldMatrix); } return materixList; } public void HideChild() { for (var i = 0; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(false); } } void Update() { luaUpdateAction?.Invoke(); } public static bool GetSupportInstancing() { return SystemInfo.supportsInstancing; } } }