gameplay frame rate drops sometimes. need suggestion.

sometimes = when functions dealing with ui elements are called, when functions “that calls another function from another scripts” are called.
its not significant, but noticeable frame rate drop.
I’m new to programming so too many small scripts rather than one big script is a way to go for me
so I was thinking if I combine combinable scripts and make few big scripts instead of too many small scripts, will it solve the problem ?

Likely combining your small scripts wont fix the real problem at hand, its more likey that whatever you are doing in “certain” functions is just slow and or unoptimized. Use the Unity profiler set to deep, to figure out what specifically is slowing down your game and try to understand why. perhaps you are iterating over a huge amount of elements? of generating alot of CG (Garbage)?

One common mistake in Unity is to use GameObject.Find more than needed, if you know your script is going to need access to another object or component every frame, grab it in the Start function and store it for use… just make sure it is active when you grab it and reference it or you’ll start getting exception errors.

Sometimes the scene load order can throw things out of wack. Below is something I have used to work around scene load order using a coroutine to grab an object that I know will load but not necessarily when. Note: as I said, this is a work around and I’m fairly sure there’s a better solution out there.

some class
{
private GameObject objectref;

void start()
{
     start coroutine(grabobjectref());
}

void update()
{
     if (objectref)     // null check
          do some stuff;
}

IEnumerator grabobjectref()
{
     while(!objectref)
     {
           objectref = GameObject.Find(the object);
           yield return null;
      }
}
}

Edit: if your scene isn’t complex or you aren’t doing any sort of asynchronous loading this won’t even be necessary.