public SequencerVariableModel clone() { SequencerVariableModel newVariable = new SequencerVariableModel(); newVariable.name = name; newVariable.value = value; return newVariable; }
void doImportSequencerFile() { string[] splitFile = fileData.text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); GameObject newDataHolder = new GameObject("sequencerDataHolderObject"); SequencerData data = newDataHolder.AddComponent<SequencerData>(); string currentType = ""; SequencerSectionModel lastSectionModel = null; for (int i=0; i < splitFile.Length; i++) { if (splitFile [i].Contains("TARGETS:")) { currentType = "targets"; continue; } else if (splitFile [i].Contains("VARIABLES:")) { currentType = "variables"; continue; } else if (splitFile [i].Contains("SECTIONS:")) { currentType = "sections"; continue; } string[] splitLine = splitFile [i].Split(new char[] {'╫'}); if (currentType == "targets") { SequencerTargetModel targetModel = new SequencerTargetModel(); targetModel.nickname = splitLine [0]; targetModel.type = splitLine [2]; GameObject goalTarget = GameObject.Find(splitLine [1]); if (goalTarget != null) targetModel.target = goalTarget; data.targets.Add(targetModel); } else if (currentType == "variables") { SequencerVariableModel variableModel = new SequencerVariableModel(); variableModel.name = splitLine [0]; variableModel.value = splitLine [1]; data.variables.Add(variableModel); } else if (currentType == "sections") { if (splitLine [0] == "section:") { lastSectionModel = new SequencerSectionModel(); lastSectionModel.commandList = new List<SequencerCommandBase>(); lastSectionModel.name = splitLine [1]; data.sections.Add(lastSectionModel); continue; } else { SequencerCommandBase command = ScriptableObject.CreateInstance(splitLine [0]) as SequencerCommandBase; command.init(lastSectionModel.name, data); command.initFromSequncerSerializedString(splitLine); lastSectionModel.commandList.Add(command); } } } Debug.LogWarning("Done, importing file"); }