Calling function found on hundreds objects(best way?)

Hi.
I ve been building a script that every 0.1 seconds calls a function on around 250 objects.
Game runs fine, but I see 250 cpu calls on the script, so I am wondering if thats fine.

The “main” script looks like this;

	GameObject[] lods;
	float dist;
	Transform player;
	MeshRenderer[] renders;
	int update_time;


	// Use this for initialization
	void Start () 
	{
		lods = GameObject.FindGameObjectsWithTag("as_lod");
		print( lods.Length );
		InvokeRepeating("lod_Check", 0, 0.1F);
	}
	
	// Update is called once per frame
	void lod_Check () 
	{
		foreach( GameObject ob in lods )
		{
			ob.SendMessage("render_check");
		}
	}

Is there a better way to call functions on multiple objects or is this fine?
The other objects have to do a vec3 distance check ,each time they get called.

Thanks for your time.

There are many faster ways to do this than SendMessage. Note this old topic: SendMessage Slows down Unity Dramatically - Questions & Answers - Unity Discussions

Not to say that SendMessage isn’t handy for when you’re still starting to implement things. But when it’s time to clean up and optimize (or it was already slowing down to begin with), SendMessage should be one of the first things to go.

There was a Unity Tips video about this a while back with Tim Cooper as the speaker: Unite 2013 - Internal Unity Tips and Tricks - YouTube

He recommends that all your instances register to a centralized/singleton script by passing itself (this) to it. It would probably then add it to a List or array. Then just foreach that array.

You already have the lods GameObject array so you probably don’t need the self-registry system. Just store a List and find all those components at load time using GetComponent and adding it to the List. Then foreach the List, calling render_check().

btw, you’re using unusual naming for your method names. The standard for C# methods is PascalCase.
Are you new to Unity?