Adding prefabs to Monobehaviour Class Array
public Transform weaponHold;
//Gun is MonoBehaviour CLass
public Gun[] allGuns = new Gun[5];
Gun equippedGun;
void Start() {
allGuns[0] = (Gun)Resources.Load ("Gun 01");
}
Im trying to load the prefabs to the Gun Array But its still not working.
Answer by phocker · Jan 04, 2017 at 09:40 PM
So you usually create an Array (or List) of Monobehaviours like this so they can be added from within the Editor. It looks like you are trying to determine the size of an Array from the Editor, and then load resources at runtime into the Array.
What is it that you are trying to do?
Your answer
Follow this Question
Related Questions
Array index is out of range? also my clone stars disappear once i click reset need help 1 Answer
Spawning prefab to an array, but array is empty and prefab is just in hierarchy. 1 Answer
Instantiating prefabs from an array of GameObjects 3 Answers
[HELP C#] Making Gameobject 1 equal Prefab 2 1 Answer
Instantiated Buttons to have separate On-click functions 0 Answers