/// <summary> /// Instantiates a new `SequenceOverlayEntity` prefab and returns its corresponding `InputSequence` /// </summary> public InputSequence CreateSequence(string text, Transform worldTarget) { SequenceOverlayEntity entity = Instantiate(_sequenceEntityPrefab, transform); _spawnedSequences.Add(entity); // Keep name updated. entity.Sequence.OnTextUpdated += delegate { entity.name = $"Sequence: {entity.Sequence.Text}"; }; entity.Target = worldTarget; entity.MoveToTargetPosition(); entity.Sequence.Text = text; entity.Sequence.OnCompleted += delegate { InputSequenceManager.UnregisterSequence(entity.Sequence); _spawnedSequences.Remove(entity); }; entity.Sequence.OnRemoval += delegate { _spawnedSequences.Remove(entity); Destroy(entity.gameObject); }; return(entity.Sequence); }
private void OnDestroy() { InputSequenceManager.UnregisterSequence(this); }