public void ComputeMinMaxNormals(object[] nmlMeshIds, AnimatorEditor dstAnimatorEditor, object[] adjacentAnimatorEditorMeshIdPairs, double adjacentSquaredDistance, bool worldCoordinates) { string path = Path.GetDirectoryName(Parser.file.Parser.FilePath); string file = Path.GetFileNameWithoutExtension(Parser.file.Parser.FilePath); string backupExt = Path.GetExtension(Parser.file.Parser.FilePath); backupExt = backupExt == String.Empty ? backupExt = "None" : backupExt.Substring(1); backupExt = (string)Properties.Settings.Default["BackupExtension" + backupExt]; UnityParser srcFileParser = new UnityParser(path + @"\" + file + ".bak0" + backupExt); Unity3dEditor srcFileEditor = new Unity3dEditor(srcFileParser); srcFileEditor.GetAssetNames(true); Animator srcAnimator = null; if (dstAnimatorEditor.Parser.classID() != UnityClassID.Animator) { Component baseAsset = srcFileParser.Cabinet.Components.Find ( delegate(Component asset) { return(asset is NotLoaded && asset.classID() == UnityClassID.GameObject && ((NotLoaded)asset).Name == dstAnimatorEditor.Parser.m_GameObject.instance.m_Name); } ); srcAnimator = srcFileEditor.OpenVirtualAnimator(srcFileParser.Cabinet.Components.IndexOf(baseAsset)); } else { Component baseAsset = srcFileParser.Cabinet.Components.Find ( delegate(Component asset) { return(asset is NotLoaded && asset.classID() == UnityClassID.Animator && ((NotLoaded)asset).Name == dstAnimatorEditor.Parser.m_GameObject.instance.m_Name); } ); srcAnimator = srcFileEditor.OpenAnimator(srcFileParser.Cabinet.Components.IndexOf(baseAsset)); } AnimatorEditor srcAnimatorEditor = new AnimatorEditor(srcAnimator); Component srcNmlAsset = srcFileParser.Cabinet.Components.Find ( delegate(Component asset) { return(asset is NotLoaded && asset.classID() == UnityClassID.MonoBehaviour && ((NotLoaded)asset).Name == Parser.m_Name); } ); NmlMonoBehaviour srcNml = srcFileEditor.OpenNmlMonoBehaviour(srcFileParser.Cabinet.Components.IndexOf(srcNmlAsset)); ComputeMinMaxNormals(nmlMeshIds, dstAnimatorEditor, srcNml, -1, srcAnimatorEditor, adjacentAnimatorEditorMeshIdPairs, adjacentSquaredDistance, worldCoordinates); }
public void ComputeUVNormalBlendData(object[] uvnbMeshIds, AnimatorEditor dstAnimatorEditor, object[] adjacentAnimatorEditorMeshIdPairs, double adjacentSquaredDistance, bool worldCoordinates) { string path = Path.GetDirectoryName(Parser.file.Parser.FilePath); string file = Path.GetFileNameWithoutExtension(Parser.file.Parser.FilePath); string backupExt = Path.GetExtension(Parser.file.Parser.FilePath); backupExt = backupExt == String.Empty ? "None" : backupExt.Substring(1); backupExt = (string)Properties.Settings.Default["BackupExtension" + backupExt]; UnityParser srcFileParser = new UnityParser(path + @"\" + file + ".bak0" + backupExt); Unity3dEditor srcFileEditor = new Unity3dEditor(srcFileParser); srcFileEditor.GetAssetNames(true); Animator srcAnimator = null; if (dstAnimatorEditor.Parser.classID() != UnityClassID.Animator) { Component baseAsset = srcFileParser.Cabinet.Components.Find ( delegate(Component asset) { return(asset is NotLoaded && asset.classID() == UnityClassID.GameObject && ((NotLoaded)asset).Name == dstAnimatorEditor.Parser.m_GameObject.instance.m_Name); } ); srcAnimator = srcFileEditor.OpenVirtualAnimator(srcFileParser.Cabinet.Components.IndexOf(baseAsset)); } else { Component baseAsset = srcFileParser.Cabinet.Components.Find ( delegate(Component asset) { return(asset is NotLoaded && asset.classID() == UnityClassID.Animator && ((NotLoaded)asset).Name == dstAnimatorEditor.Parser.m_GameObject.instance.m_Name); } ); srcAnimator = srcFileEditor.OpenAnimator(srcFileParser.Cabinet.Components.IndexOf(baseAsset)); } AnimatorEditor srcAnimatorEditor = new AnimatorEditor(srcAnimator); Transform srcUVNBFrame = srcAnimatorEditor.Frames.Find ( delegate(Transform asset) { return(asset.m_GameObject.instance.m_Name == Parser.m_GameObject.instance.m_Name); } ); UVNormalBlendMonoBehaviour srcUVNB = null; srcUVNBFrame.m_GameObject.instance.m_Component.Find ( delegate(KeyValuePair <UnityClassID, PPtr <Component> > componentEntry) { Component asset = componentEntry.Value.asset; if (asset is NotLoaded && asset.classID() == UnityClassID.MonoBehaviour && ((NotLoaded)asset).replacement is UVNormalBlendMonoBehaviour) { srcUVNB = asset as UVNormalBlendMonoBehaviour; return(true); } if (asset is UVNormalBlendMonoBehaviour) { srcUVNB = (UVNormalBlendMonoBehaviour)asset; return(true); } return(false); } ); ComputeUVNormalBlendData(uvnbMeshIds, dstAnimatorEditor, srcUVNB, -1, srcAnimatorEditor, adjacentAnimatorEditorMeshIdPairs, adjacentSquaredDistance, worldCoordinates); }