/* * Selection move */ void OnStartDragObject(ObjectUI objectUi) { // check for individual selection if (AddSelection(objectUi)) { // remove old selection if (_currentSelection.objectUi != null && _currentSelection.objectUi != _selectedObjects[objectUi.beatObjectData.id].objectUi) { RemoveSelection(_currentSelection.objectUi); } _currentSelection = _selectedObjects[objectUi.beatObjectData.id]; // remove all other selections List <int> tempKeys = new List <int>(_selectedObjects.Keys); foreach (var key in tempKeys) { SelectedObjectData selectedObject = _selectedObjects[key]; if (selectedObject.beatObjectData.id != objectUi.beatObjectData.id) { RemoveSelection(selectedObject.objectUi); } } } CalculateOffsets(ref _selectedObjects, objectUi.beatObjectData.time, objectUi.beatObjectData.editorLayer); }
public void AddObject(BeatObjectData data) { ObjectUI objectUi = Instantiate(_objectUiInstance, _rectObjectsList).GetComponent <ObjectUI>(); objectUi.Init(data, _timeline); objectUi.onStartDrag.AddListener(OnStartDragObject); objectUi.onDrag.AddListener(OnDragObject); objectUi.onStopDrag.AddListener(OnStopDragObject); UpdateObject(objectUi); if (_drawOnlyBeatKeys) { objectUi.ShowOnlyKey(true); } _objectsUi.Add(objectUi.beatObjectData.id, objectUi); }
bool AddSelection(ObjectUI objectUi) { if (_selectedObjects.ContainsKey(objectUi.beatObjectData.id)) { return(false); } SelectedObjectData newSelectedObject = new SelectedObjectData { objectUi = objectUi }; objectUi.OnSelect(); _selectedObjects.Add(objectUi.beatObjectData.id, newSelectedObject); ObjectProperties.instance.SelectedObjects = _selectedObjects; return(true); }
void OnDragObject(ObjectUI objectUi) { List <int> keys = new List <int>(_selectedObjects.Keys); foreach (var key in keys) { SelectedObjectData newSelectedObject = _selectedObjects[key]; BeatObjectData data = newSelectedObject.beatObjectData; // offsetting beat objects while moving if (!InputData.shouldOnlyLayer) { data.time = Mathf.Max(0, mouseTime + newSelectedObject.offset); } data.editorLayer = Mathf.Max(0, mouseLayer + newSelectedObject.offsetLayer); if (InputData.shouldSnap) { data.time = Mathf.Round(data.time); } UpdateObject(newSelectedObject.objectUi); } }
public void UpdateObject(ObjectUI objectUi) { objectUi.UpdateUI(); }
void OnStopDragObject(ObjectUI objectUi) { LevelDataManager.instance.SortBeatObjects(); }
void RemoveSelection(ObjectUI objectUi) { objectUi.OnDeselect(); _selectedObjects.Remove(objectUi.beatObjectData.id); }