- Home /
What to use to store data like eg. block types?
What should I use to store data that will not be modified but only accessed to find out some things.
Eg. DirtBlock could store data like: prefab, color, strength, biome and others.
Also how to make an array of these blocks types (BlockTypes) that can be accessed in an easy way? With eg. enum type:
enum BlockType { Block1, Block2, Block3 }
this.prefab = BlockTypes[BlockType.Block1].prefab;
Answer by nixcs2512 · Aug 02, 2013 at 01:04 PM
If you wanna only accessed but don't let anyone modify it when play game, you can store variable like that (C#):
public class Block()
{
int _storeInt;
public int StoreInt
{
get { return _storeInt;}
}
}
so when you want to call _storeInt, just simply call StoreInt.
I don't know what you mean with 2nd question, when you created an array of BlockTypes, you can access easily to all public variables of that class.
Your answer
![](https://koobas.hobune.stream/wayback/20220613111421im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Enum vs Array (js) 1 Answer
Reading and Storing External Data into Memory (From Text) 1 Answer
Problem with moving objects in array? 2 Answers
Passing an Array 1 Answer
Problem sending array to unity player using SendMessage 1 Answer