- Home /
Change Prefab Source/Change material on ALL prefabs in the scene
Hello everyone!
I really hope someone can help me:)
I have made an endless tunnel made out of different object. The player moves forward. By clicking I want to change these objects (size,material,animation,etc.) This works.
But.. Because I work with prefabs, only the prefab changes that I've clicked. Unless it's the source of the prefabs (the first tunnel).
Does anyone know how to change ALL the prefabs that are instantiated. Also when they already are in the scene? (so that the change made by clicking remains constant)
var tunnel : Transform;
private var CreateTimer = 2.0;
private var NextCreate = 0.0;
public static var count = 0;
function Update()
{
transform.Translate(Vector3.forward * (15 * Time.deltaTime));
if (Time.time > CreateTimer + NextCreate)
{
NextCreate = Time.time;
for (var i : int = 0; i < 1; i++)
{
count++;
Instantiate(tunnel, new Vector3(72.5, 26.5,count * 150), Quaternion.Euler(0, 0, 180));
}
}
}
public var TargetPlane : GameObject;
function OnMouseDrag ()
{
TargetPlane.renderer.sharedMaterial.color -= Color(0.1, 0, 0) * Time.deltaTime;
}
Your answer
Follow this Question
Related Questions
Instantiate Object At Local Position 2 Answers
copy enemy prefabs 1 Answer
Instantiate Clones Itself - Rather than Prefab 0 Answers
Can't remove instantiated prefab 0 Answers
Can I stop the prefab connection of a gameobject during play? 1 Answer