Given I have a reference to a battle grid cell I want to modify from another C# script, how do I access/modify the cell type property?

image
  • Via the cell component's CellTypeOverride property, where you'd assign the cell type's settings (or null to reset it).
    E.g. if you have the asset of the cell type, you can do it like this:
    cell.CellTypeOverride = cellTypeAsset.Settings;
    cell is a BattleGridCellComponent and cellTypeAsset a BattleGridCellTypeAsset.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for answering. I do have a follow up question:

    How do I change the cellTypeAsset.Settings (to another element from the dropdown) from another script (after finding the cell by name)?

    For example, I want to change a cell from ground to blocked from another script.
  • Well, the cellTypeAsset is just that, the asset of the cell type you want to use. If you're talking about ORK's dropdown settings to select those, they have the asset available as StoredAsset property, e.g.:
    BattleGridCellTypeAsset cellTypeAsset = yourPopupField.StoredAsset;
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for the answer. We found a different solution that also worked.

    What we ended up doing is using a CellTypeOverride to apply the settings from the BattleGridCellType prefab we want the cell to turn into. Seems to work fine.
    child.GetComponent().CellTypeOverride = tilePrefabs.tileTypeB.Settings;
Sign In or Register to comment.