Multi-Floors Visibility
parent
9b78768a79
commit
7a789484f9
@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Grid;
|
||||
using UnityEngine;
|
||||
|
||||
public class FloorVisibility : MonoBehaviour {
|
||||
[SerializeField] private float floorHeightOffset = 2f;
|
||||
[SerializeField] private bool dynamicFloorPosition;
|
||||
[SerializeField] private List<Renderer> ignorRendererList;
|
||||
private int floor;
|
||||
private Renderer[] rendererArray;
|
||||
private void Awake() => rendererArray = GetComponentsInChildren<Renderer>(true);
|
||||
|
||||
private void Start() {
|
||||
floor = LevelGrid.GetFloor(transform.position);
|
||||
if (floor == 0 && !dynamicFloorPosition) Destroy(this);
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (dynamicFloorPosition) floor = LevelGrid.GetFloor(transform.position);
|
||||
Show(CameraController.Instance.CameraHeight > LevelGrid.FLOOR_HEIGHT * floor + floorHeightOffset || floor == 0);
|
||||
}
|
||||
|
||||
private void Show(bool showing) {
|
||||
foreach (Renderer rendererItem in rendererArray) {
|
||||
if (ignorRendererList.Contains(rendererItem)) continue;
|
||||
rendererItem.enabled = showing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a5a73cbbbae15cd2acb85efcfc98557
|
||||
@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2023.2.0b4
|
||||
m_EditorVersionWithRevision: 2023.2.0b4 (f15431dc5dc1)
|
||||
m_EditorVersion: 2023.2.0b5
|
||||
m_EditorVersionWithRevision: 2023.2.0b5 (da89774450b8)
|
||||
|
||||
Loading…
Reference in New Issue