unity – Best practice in regard to script management and resource usage?

I’m currently working to make a game, and it’s a first for both of us.

We are at the point where we are starting to have a lot of scripts pile up, and are wondering about the resource management & resource impact on having a lot of small scripts running.

Is there any drawback to having multiple scripts only doing one thing, as opposed to one large script?

For example, one of our scripts only contains this following code, and is likely to not change, but all it does is destroy the object after it’s hit twice;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PartsController : MonoBehaviour
    int collisionCounter;
    void OnTriggerEnter2D(Collider2D other)
        if (other.gameObject.tag == "Projectile")
            collisionCounter += 1;
            if (collisionCounter >= 2)

Would we be better off trying to nest things like this into a larger script, instead of running several small ones?

Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email