private static void ReplaceObjectReference(Dictionary <string, TemplateAsset> assetDictionary, TemplateProperty property, Dictionary <string, string> replaceList) { var replaceGuidPairDictionary = CreateReplaceGuidPairDictionary(assetDictionary); var replaceNamePairDictionary = CreateReplaceNamePairDictionary(property, replaceList); if (replaceGuidPairDictionary.Count > 0) { foreach (var ta in assetDictionary.Values) { IReferenceModifier modifier = BuildReferenceModifier(ta, replaceGuidPairDictionary, replaceNamePairDictionary); if (modifier != null) { modifier.Modify(ta.destinationPath); } } } }
private static IReferenceModifier BuildReferenceModifier(TemplateAsset ta, Dictionary <string, string> replaceGuidPairDictionary, Dictionary <string, string> replaceNamePairDictionary) { if (ta.IsDummyAsset || ta.IsFolder) { return(null); } IReferenceModifier modifier = null; if (AssetDatabase.GetMainAssetTypeAtPath(ta.templatePath) == typeof(AnimationClip)) { modifier = new AnimationClipReferenceModifier(replaceNamePairDictionary); } else if (Path.GetExtension(ta.templatePath).Equals(".fbx", StringComparison.OrdinalIgnoreCase)) { modifier = new FbxReferenceModifier(replaceGuidPairDictionary); } else { modifier = new GuidReferenceModifier(replaceGuidPairDictionary); } return(modifier); }