/// <summary> /// Write the prefab to a new file /// </summary> /// <param name="parsedPrefab"></param> /// <param name="currentPrefab"></param> /// <param name="destination"></param> public void SavePrefabFile(string[] parsedPrefab, PrefabModel currentPrefab, string destination) { // string newPrefabMetaPath = destination + @"\" + Path.GetFileName(currentPrefab.MetaPath); string newPrefabMetaPath = destination + currentPrefab.MetaPath.GetRelativeAssetPath(); if (!Administration.Instance.OverWriteMode) { newPrefabMetaPath = ProjectPathUtility.AddTimestamp(newPrefabMetaPath); } if (!Directory.Exists(Path.GetDirectoryName(newPrefabMetaPath))) { Directory.CreateDirectory(Path.GetDirectoryName(newPrefabMetaPath)); } // For when copying to the same project if (currentPrefab.MetaPath != newPrefabMetaPath) { File.Copy(currentPrefab.MetaPath, newPrefabMetaPath, true); } string newPrefabPath = newPrefabMetaPath.Substring(0, newPrefabMetaPath.Length - 5); if (!Directory.Exists(Path.GetDirectoryName(newPrefabPath))) { Directory.CreateDirectory(Path.GetDirectoryName(newPrefabPath)); } File.WriteAllText(newPrefabPath, string.Join("\r\n", parsedPrefab)); Debug.Log("Migrated prefab to : " + newPrefabPath); }
/// <summary> /// Change the fields after merging with the merging window /// </summary> /// <param name="originalScriptMappings"></param> /// <param name="rootPath"></param> /// <param name="scenePath"></param> /// <param name="linesToChange"></param> /// <param name="mergedScriptMappings"></param> private void MergingWizardCompleted(List <ScriptMapping> originalScriptMappings, string rootPath, string scenePath, string[] linesToChange, List <ScriptMapping> mergedScriptMappings = null) { if (mergedScriptMappings != null) { originalScriptMappings = originalScriptMappings.Merge(mergedScriptMappings); } ThreadUtility.RunTask(() => { fieldMappingController.MigrateFields(scenePath, ref linesToChange, ref originalScriptMappings, ProjectPathUtility.getProjectPathFromFile(scenePath), rootPath); string newScenePath = rootPath + scenePath.GetRelativeAssetPath(); if (!Administration.Instance.OverWriteMode) { newScenePath = ProjectPathUtility.AddTimestamp(newScenePath); } mappingView.SaveScriptMappings(rootPath, originalScriptMappings); SaveSceneFile(newScenePath, linesToChange); }); }