Transform Scale of multiple objects using Slider UI
Hello there, I'm a beginner in Unity as well as C#. I'm trying find a simpler way to transform the scale of multiple objects (around 200) using a single slider. Here's the code I've written.
public class GrowingTree : MonoBehaviour { Vector3 tempScale; public void adjustGrowth(float rateGrowth) { tempScale = transform.localScale; tempScale.x = rateGrowth; tempScale.y = rateGrowth; tempScale.z = rateGrowth; transform.localScale = tempScale; } }
This is working but I have to manually add all the objects in the editor under the slider inspector. The objects are tagged "Tree" but I can't find way to access them in the scripts along with the slider. Also many objects with the same script are making the scene too slow. So far I've tried implementing functions like "FindObjectsWithTag". Please help!