public static FSequence CreateSequence() { // find new name & priority for sequence string sequenceNameFormat = FSettings.SequenceName + "_{0}"; int sequenceId = 0; string sequenceName = string.Format(sequenceNameFormat, sequenceId.ToString("000")); FSequence[] sequences = FindObjectsOfType <FSequence>(); for (int i = 0, limit = sequences.Length; i != limit; ++i) { if (sequences[i].name == sequenceName) { // try new name ++sequenceId; sequenceName = string.Format(sequenceNameFormat, sequenceId.ToString("000")); i = -1; // restart search } } FSequence sequence = FSequence.CreateSequence(sequenceName); sequence.name = sequenceName; sequence.Length = FSettings.DefaultLength; Undo.RegisterCreatedObjectUndo(sequence.gameObject, "Create Sequence"); return(sequence); }
public static FSequence CreateSequence(string seqName = null) { // find new name & priority for sequence string sequenceNameFormat = "Sequence_{0}"; int sequenceId = 0; string sequenceName = string.IsNullOrEmpty(seqName) ? string.Format(sequenceNameFormat, sequenceId.ToString("000")) : seqName; FSequence[] sequences = FindObjectsOfType <FSequence>(); for (int i = 0, limit = sequences.Length; i != limit; ++i) { if (sequences[i].name == sequenceName) { // try new name ++sequenceId; sequenceName = string.Format(sequenceNameFormat, sequenceId.ToString("000")); i = -1; // restart search } } FSequence sequence = FSequence.CreateSequence(); sequence.name = sequenceName; sequence.FrameRate = FUtility.FrameRate; sequence.Length = sequence.FrameRate * FSequence.DEFAULT_LENGTH; Undo.RegisterCreatedObjectUndo(sequence.gameObject, "Create Sequence"); return(sequence); }