Example #1
0
    void doRenameSection(SequencerSectionModel renameSectionModel, string newName)
    {
        //cant be blank name
        newName = newName.Trim();
        if (newName == null || newName.Length == 0)
        {
            Debug.Log("Cant rename to blank!");
            return;
        }

        //check for unique section name
        foreach (SequencerSectionModel model in sequencerData.sections)
        {
            if (renameSectionModel != model && model.name == newName)
            {
                Debug.LogWarning("Could not rename to " + newName + " because another section is already named that way !");
                return;
            }
        }

        int numberOfRefrences = 0;
        //make sure references are updated in all sections
        foreach (SequencerSectionModel sectionModel in sequencerData.sections)
        {
            foreach (SequencerCommandBase command in sectionModel.commandList)
            {
                bool wasUpdated = command.updateSectionReference(renameSectionModel.name, newName);

                if (wasUpdated)
                    numberOfRefrences += 1;
            }
        }

        Debug.Log("Updated " + numberOfRefrences + " to this sections.");

        //do rename
        renameSectionModel.rename(newName);
    }