Skip to content
Snippets Groups Projects
ForestElementsManager.cs 782 B
Newer Older
  • Learn to ignore specific revisions
  • using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class ForestElementsManager : MonoBehaviour
    {
    
        [SerializeField] bool smallObjectsCollision = false;
    
        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);
            }
        }
    }