[Range(3, 100)]
public int mapWidth = 10;
[Range(3, 100)]
public int mapHeight = 10;
I want to do that when i change the value with the slider in the Inspector of mapWidth it will change also the value of mapHeight and same if i change the mapHeight. Or to disable not to hide the mapHeight range slider so it will move when moving the mapWidth range slider but the user will not be able to change the mapHeight only with the mapWifth.
I need this since i want that always the values in mapWidth and mapHeight will be same.
This will do that, but why even make height a slider at that point?
[Range(3, 100)]
public int mapWidth;
[Range(3, 100)]
public int mapHeight;
private void OnValidate() {
mapHeight = mapWidth;
}
As for being able to change either and the other one mirror the value, you’d need to store the “current” value and then detect which one changed, and change the other one to match.
Thank you in the end i’m using one global variable mapSize with Range. And i create the map/grid onlt with the mapSize so i don’t need to update other variables and not using OnValidate.