public DecalEntityManager Get() { if (m_DecalEntityManager == null) { Assert.AreEqual(m_ReferenceCounter, 0); m_DecalEntityManager = new DecalEntityManager(); var decalProjectors = GameObject.FindObjectsOfType <DecalProjector>(); foreach (var decalProjector in decalProjectors) { if (!decalProjector.isActiveAndEnabled || m_DecalEntityManager.IsValid(decalProjector.decalEntity)) { continue; } decalProjector.decalEntity = m_DecalEntityManager.CreateDecalEntity(decalProjector); } DecalProjector.onDecalAdd += OnDecalAdd; DecalProjector.onDecalRemove += OnDecalRemove; DecalProjector.onDecalPropertyChange += OnDecalPropertyChange; DecalProjector.onDecalMaterialChange += OnDecalMaterialChange; } m_ReferenceCounter++; return(m_DecalEntityManager); }
private void OnDecalAdd(DecalProjector decalProjector) { if (!m_DecalEntityManager.IsValid(decalProjector.decalEntity)) { decalProjector.decalEntity = m_DecalEntityManager.CreateDecalEntity(decalProjector); } }