Cesium for Unity 1.15.2
Loading...
Searching...
No Matches
CesiumObjectPools.cs
Go to the documentation of this file.
1using UnityEngine;
2
3#if UNITY_EDITOR
4using UnityEditor;
5#endif
6
7namespace CesiumForUnity
8{
9 internal class CesiumObjectPools
10 {
11 public static CesiumObjectPool<Mesh> MeshPool => _meshPool;
12
13 private static CesiumObjectPool<Mesh> _meshPool;
14
15 public static void Dispose()
16 {
17 _meshPool.Dispose();
18 }
19
20 static CesiumObjectPools()
21 {
22 _meshPool = new CesiumObjectPool<Mesh>(
23 () => new Mesh(),
24 (mesh) => mesh.Clear(),
25 (mesh) => UnityLifetime.Destroy(mesh));
26
27#if UNITY_EDITOR
28 EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
29#endif
30 }
31
32#if UNITY_EDITOR
33 private static void OnPlayModeStateChanged(PlayModeStateChange obj)
34 {
35 Dispose();
36 }
37#endif
38 }
39}