- Home /
get all scripts attached to gameobject
how can i get references to all scripts attached to a gameObject? thanks
Answer by zmar0519 · Apr 18, 2011 at 12:02 PM
try gameObject.GetComponents(MonoBehaviour)
. Since all scripts that you can write derive from mono(unless you state that it extends mono, in which case you will have to manually refrence those), it will return all the components. In order to store them, us an array of type mono.
Just one question, with this option yu get the components but then if you want to work with them you have to do a casting for each component, isn't it?
Answer by Aldwoni_legacy · Apr 18, 2011 at 12:09 PM
Gameobject ng93; ng93 = new GameObject("NG93");
NG93.AddComponent("Scriptname1"); NG93.AddComponent("Scriptname2");
Your answer
Follow this Question
Related Questions
How to acces Shininess from a Shader in script C# 2 Answers
Having a particle effect stick to player 0 Answers
how to build & populate an array available to all scripts on all objects? 1 Answer
How could I get a selection set of GameObject sharing a material or a script in Editor? 1 Answer
Can't destroy a script. 1 Answer