Skip to content
Snippets Groups Projects
ForestElementsManager.cs 793 B
Newer Older
  • Learn to ignore specific revisions
  • using UnityEngine;
    
    public class ForestElementsManager : MonoBehaviour
    {
    
        [SerializeField] bool smallObjectsCollision = false;
    
    
        //TODO: decide on convention: disable in editor, or here, not both
    
        private System.Action<GameObject> disableSmallObjectCollision = (gameObj) =>
        {
            if (gameObj.name.Contains("Grass_01") || gameObj.name.Contains("Grass_02") || gameObj.name.Contains("Mushroom_01") || gameObj.name.Contains("Mushroom_02") || gameObj.name.Contains("Branch_01"))
            {
                gameObj.GetComponent<MeshCollider>().enabled = false;
            }
        };
    
        // Start is called before the first frame update
        void Start()
        {
            if (!smallObjectsCollision)
            {
                gameObject.ForAllChildren(disableSmallObjectCollision);
            }
        }
    }