Fastest way to instantiate and move multiple game objects in the editor

Hello everybody :)

I have a script editor that instantiate a large number of small objects in my scene, around 1000 units.

This takes a lot of time to complete (around 15 sedonds) which is not really a problem for the creation.

However this editor script allows me also to move (translation + rotation) all these objects at once and this operation takes almost the same time. This is quite annoying because I have to move these objects quite often while editing my scene.

Is there some way to improve these instantiation and moving actions?

Here is a snippet of my code:

     List<GameObject> m_CurveObjects = new List<GameObject>();

// Draw abject along a curve
                while (position < curve.Length)
                {
                        curveGameObject = (GameObject) Instantiate(CurveObject);
                        curveGameObject.isStatic = true;
                        m_CurveObjects.Add(curveGameOject);
                    }

                    curveGameObject.transform.localPosition = newposition;
                    trackGameObject.transform.rotation = new Quaternion();
                    trackGameObject.transform.Rotate(myangle1, myAngle2, myAngle3);

                    position += SpaceBetweenObjects;

                }
                position -= segment.Length;
            }

When I only move the objects, I do the same things, but instead of instantiating I go through the list where I stored my objects.

Are you sure you really need to instantiate 1000 GameObjects for that purpose?

It seems to me that you are making some sort of curve from several dummy objects (transforms) which would only slow your game down. It might be easier to just create a list of CurvePoints that isn't derived from MonoBehaviour and work on that set of objects instead. If you still want to be able to manipulate them through the editor, you could create an editor script that do this for you. Of course, I don't fully know what you intend to do with these GameObjects you're creating, but I thought it might still be worth mentioning. If you want to be able to store the list you need to add System.Serializable attribute to the class.

Try adding a:

yield;

anywhere in the while(){} block. It should allow for a frame to go between each manipulation, making the total process longer, but restoring control ( aka: not freezing).

I think it could help.

hello how can i control the animation applied on multiple gameobjects i used the script=====
public var timer : float =0.0;
var apple : GameObject;
function Update(){
timer += Time.deltaTime;
if(animation.IsPlaying(“bounce”))
{
Debug.Log(“Mellon is bouncing”+timer);

// apple.animation.Play(“AppleBounce”);
apple.animation.Stop(“AppleBounce”);
}
// animation.Stop(“AppleBounce”);
if(timer>=3 && timer<6)
{
animation.Stop(“bounce”);
// Debug.Log(“Mellon is bouncing”);
apples(apple,“AppleBounce”);
Debug.Log(“function return in calling fn”+timer);
// animation.Play(“MelonBounce”);
//timer=0.0;

}
if(timer>=9 && timer<=12)
{
Debug.Log(“comes in timer”+timer);
apple.animation.Play(“AppleBounce”);
animation.Play(“bounce”);
Debug.Log(“both are playing”+timer);
}
}

function apples(apple:GameObject,animName:String)
{
apple.transform.animation.Play(“AppleBounce”);
Debug.Log(“Apple is bouncing”+timer);
if(timer>6 && timer< 9)
{
animation.Stop(“AppleBounce”);
//multiObject()
}
return;
}