void SetUpArray(SO_RuleTile levels) { if (levels.rules != null && levels.rules.Count > 0) { for (int i = 0; i < levels.rules.Count; i++) { EditorGUILayout.LabelField("Rule number " + i); EditorGUILayout.BeginHorizontal(); levels.rules[i].array[6] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[6], GUILayout.Width(50)); levels.rules[i].array[7] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[7], GUILayout.Width(50)); levels.rules[i].array[8] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[8], GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); levels.rules[i].array[3] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[3], GUILayout.Width(50)); levels.rules[i].array[4] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[4], GUILayout.Width(50)); levels.rules[i].array[5] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[5], GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); levels.rules[i].array[0] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[0], GUILayout.Width(50)); levels.rules[i].array[1] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[1], GUILayout.Width(50)); levels.rules[i].array[2] = (MapTile.TileType)EditorGUILayout.EnumPopup(levels.rules[i].array[2], GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); } } }
void CreateArray(SO_RuleTile levels) { if (levels.rules == null || levels.rules.Capacity == 0) { levels.rules = new List <SO_RuleTile.Rule>(); } if (firstDimensionSize == previousSize) { return; } if (firstDimensionSize < previousSize) { for (int i = previousSize; i > firstDimensionSize; i--) { levels.rules.RemoveAt(i - 1); } } if (firstDimensionSize > previousSize) { for (int i = 0; i < firstDimensionSize - previousSize; i++) { levels.rules.Add(new SO_RuleTile.Rule(9)); } } previousSize = firstDimensionSize; }
void CreateNewArray(SO_RuleTile levels) { GetDimensions(); if (ConfirmedCanCreate()) { CreateArray(levels); } }
public override void OnInspectorGUI() { serializedObject.Update(); SO_RuleTile levels = (SO_RuleTile)target; if (CanCreateNewArray()) { CreateNewArray(levels); } EditorGUI.BeginChangeCheck(); levels.tile = EditorGUILayout.ObjectField("Tile associated : ", levels.tile, typeof(Object), false) as Tile; levels.groundTile = EditorGUILayout.ObjectField("Tile that goes under : ", levels.groundTile, typeof(Object), false) as Tile; levels.tileType = (MapTile.TileType)EditorGUILayout.EnumPopup("Type of the tile : ", levels.tileType); EditorGUILayout.Space(); EditorGUILayout.LabelField("Set of rules for center tiles"); EditorGUILayout.LabelField("(Toggle on means it's a solid tile)"); EditorGUILayout.Space(); EditorGUILayout.LabelField("Number of rules"); SetUpArray(levels); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } EditorUtility.SetDirty(target); }