Again, I am new to programming. I have a JS class called Blocks. the code for that is:
public class Blocks
{
var name : String;
var description : String;
var blockID : int;
var prefab : Transform;
var hitsToDestroy : int;
var icon : Texture2D;
var rarity : Rareness;
}
enum Rareness
{
Common,
Uncommon,
Rare,
SuperRare,
UltraRare,
Epic
}
I also have a JS Inventory script;
import System.Collections.Generic;
//Items holder: Holds all of our blocks and tools etc
var blocks : Blocks[];
//var toolItems : ToolItems[];
//Inventory
var MainInventory : List.<Blocks> = new List.<Blocks>();
//Initialization
function Start(){
//
MainInventory.Add(blocks[1]);
MainInventory.Add(blocks[2]);
MainInventory.Add(blocks[3]);
/*
Debug.Log(MainInventory[1].name);
Debug.Log(MainInventory[1].description);
Debug.Log(MainInventory[2].name);
Debug.Log(MainInventory[2].description);
Debug.Log(MainInventory[3].name);
Debug.Log(MainInventory[3].description);
*/
}
//GUI function
function OnGUI(){
}
What I need to do is in a C# script, reference the list of blocks and from that I should be able to use MainInventory.Add(blocks[1]); and instantiate the prefab taken from MainInventory[1].prefab
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
How do I reference the class/inventory whichever in order to access the prefab stored in this array? (I think that’s right lol; new to programming)