Quantcast
Viewing latest article 2
Browse Latest Browse All 6

Answer by _Gkxd

Instead of storing the names of the classes, you can just store the list of components: Include this line at the top of your script using System.Collections.Generic; Somewhere inside the class List componentsToAdd; // Your list of components void Start() { componentsToAdd = new List(); componentsToAdd.add(/* some component */); // Repeat as necessary } When you want to add components foreach (Component c in componentsToAdd) { someGameObject.AddComponent(c.GetType()); }

Viewing latest article 2
Browse Latest Browse All 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>