48 lines
954 B
C#
48 lines
954 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Pinwheel.Griffin;
|
|
using UnityEditor.Build;
|
|
using UnityEngine;
|
|
|
|
namespace BITKit.WorldChunk
|
|
{
|
|
public class PolarisTerrainChunk : WorldChunk
|
|
{
|
|
private GTerrainChunk terrain;
|
|
private MeshRenderer meshRenderer;
|
|
private bool _isLoaded;
|
|
private Rect _rect;
|
|
|
|
private void Start()
|
|
{
|
|
terrain = GetComponent<GTerrainChunk>();
|
|
meshRenderer = GetComponent<MeshRenderer>();
|
|
|
|
var bounds = meshRenderer.bounds;
|
|
var pos = bounds.center;
|
|
var size = bounds.size;
|
|
|
|
_rect = new Rect(
|
|
pos.x,
|
|
pos.z,
|
|
size.x,
|
|
size.y
|
|
);
|
|
Add(this);
|
|
destroyCancellationToken.Register(() => { Remove(this); });
|
|
|
|
_isLoaded = gameObject.activeSelf;
|
|
}
|
|
public override Rect GetRect() => _rect;
|
|
|
|
public override void SetActive(bool active)
|
|
{
|
|
if (_isLoaded == active) return;
|
|
terrain.gameObject.SetActive(active);
|
|
_isLoaded = active;
|
|
}
|
|
}
|
|
|
|
}
|