Recording Input strokes in editor mode
Hi, I'm trying to create my own level maker as a tool to run in editor mode. However I'm having problems finding a good way to record inputs. I am able to register prefab-creation for undo, but I also want to record occupied positions in a separate datastructure (or in the undo system if possible) to be able to quickly track open/occupied positions on the board.
The code below just spawns prefabs at a given position whenever the shift key is held down. I want to be able to either reliably detect when the key is not being pressed any more (so that I can populate my own datastructure with positions what are occupied, and record the 'strokes' made within the scene) OR register custom data to the undo-system to achieve the same result, if possible.
void DuringSceneGUI(SceneView sceneview)
{
if (Event.current.shift)
{
var cell = GetCell();
if (GridPositionUtilsXZ.IsWithinGrid(cell, xSize, ySize, gridCellSize))
{
var gameObject = TryInstantiateAtCell(cell));
currentStroke.Add(gameObject, cell);
}
}
//Something Like This:
// if (Event.current.type == EventType.KeyUp)
// {
// occupiedCells.Add(currentStroke, strokeCounter++);
// currentStroke.Clear();
// }
}