- Home /
Display struct property inside another struct?
In the Editor, I can create some TileType
:
I can also define possible MapItem
's in the Editor, where I can specify which prefab should be instantiated, its type, availability (enum day, night/anytime). I also want to be able to specify which TileType
s are suitable for this MapItem
to be deployed on.
See here:
In the code below, you can see how I do this and how I have a list of TileType
defined in MapItem
. However, this is not suitable as it shows all properties of the TileType
. Instead, I'd like to show just a list of names (`TileType.Name`) linking to the created TileTypes
.
In other words, rather than seeing a list of TileType
structs in the second image, I want to see a list of Names of the TileType
structs created... Perhaps using enums? I'm not sure how.
How can I do this?
public MapItem[] PossibleMapItems;
public TileType[] TileTypes;
[System.Serializable]
public struct MapItem{
public GameObject Prefab;
public MAP_ITEM_TYPE ItemType;
public AVAILABILITY Availability;
public List<TileType> SuitableTileTypes;
}
[System.Serializable]
public struct TileType{
public string Name;
public float Height;
public Material Material;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612160653im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problems with editing a class from the editor 1 Answer
Change variable in inspector depending on enum using struct 0 Answers
Putting user defined struct in Unity Editor 4 Answers
Show and Edit Attributes of my list of structs in EditorWindow. 0 Answers
How do I delete or empty an array of custom structs during edit mode? 1 Answer