先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
namespace Crest.Examples
|
|
{
|
|
/// <summary>
|
|
/// Simple script to play / stop any child particle systems based on viewer distance from this GO.
|
|
/// </summary>
|
|
public class ParticleSystemDistanceCulling : MonoBehaviour
|
|
{
|
|
public Transform _viewpoint;
|
|
public float _maxDistance = 50.0f;
|
|
|
|
bool _emitting = true;
|
|
|
|
ParticleSystem[] _particleSystems;
|
|
|
|
private void Start()
|
|
{
|
|
_particleSystems = GetComponentsInChildren<ParticleSystem>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
var dist2 = (_viewpoint.transform.position - transform.position).sqrMagnitude;
|
|
var maxDist2 = _maxDistance * _maxDistance;
|
|
|
|
if (_emitting && dist2 > maxDist2)
|
|
{
|
|
_emitting = false;
|
|
|
|
foreach (var system in _particleSystems)
|
|
{
|
|
system.Stop();
|
|
}
|
|
}
|
|
else if (!_emitting && dist2 < maxDist2)
|
|
{
|
|
_emitting = true;
|
|
|
|
foreach (var system in _particleSystems)
|
|
{
|
|
system.Play();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|