diff --git a/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs b/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs index a930ff1a0..87470acaf 100644 --- a/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs +++ b/AlembicImporter/Assets/UTJ/Alembic/Editor/Importer/AlembicImporter.cs @@ -40,35 +40,42 @@ public static AssetMoveResult OnWillMoveAsset(string from, string to) { if (Path.GetExtension(from.ToLower()) != ".abc") return AssetMoveResult.DidNotMove; - var streamDestPath = AlembicImporter.MakeShortAssetPath(to); - var streamSourcePath = AlembicImporter.MakeShortAssetPath(from); - AlembicStream.DisconnectStreamsWithPath(streamSourcePath); - AlembicStream.RemapStreamsWithPath(streamSourcePath,streamDestPath); + var streamDstPath = AlembicImporter.MakeShortAssetPath(to); + var streamSrcPath = AlembicImporter.MakeShortAssetPath(from); + AlembicStream.DisconnectStreamsWithPath(streamSrcPath); + AlembicStream.RemapStreamsWithPath(streamSrcPath,streamDstPath); - var destPath = Application.streamingAssetsPath + streamDestPath; - var sourcePath = Application.streamingAssetsPath + streamSourcePath; + var dstPath = Application.streamingAssetsPath + streamDstPath; + var srcPath = Application.streamingAssetsPath + streamSrcPath; - var directoryPath = Path.GetDirectoryName(destPath); - if (File.Exists(destPath)) - { - File.SetAttributes(destPath + ".meta", FileAttributes.Normal); - File.Delete(destPath); - } - else if (!Directory.Exists(directoryPath)) + try { - Directory.CreateDirectory(directoryPath); + var directoryPath = Path.GetDirectoryName(dstPath); + if (File.Exists(dstPath)) + { + File.SetAttributes(dstPath + ".meta", FileAttributes.Normal); + File.Delete(dstPath); + } + else if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + if (File.Exists(dstPath)) + File.SetAttributes(dstPath, FileAttributes.Normal); + File.Move(srcPath, dstPath); + if (File.Exists(dstPath + ".meta")) + { + File.SetAttributes(dstPath + ".meta", FileAttributes.Normal); + File.Move(srcPath + ".meta", dstPath + ".meta"); + } + + AssetDatabase.Refresh(ImportAssetOptions.Default); + AlembicStream.ReconnectStreamsWithPath(streamDstPath); } - if (File.Exists(destPath)) - File.SetAttributes(destPath, FileAttributes.Normal); - File.Move(sourcePath, destPath); - if (File.Exists(destPath + ".meta")) + catch (System.Exception e) { - File.SetAttributes(destPath + ".meta", FileAttributes.Normal); - File.Move(sourcePath + ".meta", destPath+ ".meta"); + Debug.LogWarning(e); } - AssetDatabase.Refresh(ImportAssetOptions.Default); - AlembicStream.ReconnectStreamsWithPath(streamDestPath); - return AssetMoveResult.DidNotMove; } } diff --git a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicPointsRenderer.cs b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicPointsRenderer.cs index 7153c67a7..70d353ab9 100644 --- a/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicPointsRenderer.cs +++ b/AlembicImporter/Assets/UTJ/Alembic/Scripts/Importer/AlembicPointsRenderer.cs @@ -58,6 +58,7 @@ public class AlembicPointsRenderer : MonoBehaviour [SerializeField] Material[] m_materials; [SerializeField] Material m_motionVectorMaterial; [SerializeField] ShadowCastingMode m_castShadows = ShadowCastingMode.On; + [SerializeField] bool m_applyTransform = false; [SerializeField] bool m_receiveShadows = true; [SerializeField] bool m_generateMotionVector = true; [SerializeField] float m_pointSize = 0.2f; @@ -198,12 +199,24 @@ public void Flush() // update materials if(m_mpb==null) m_mpb = new MaterialPropertyBlock(); - m_mpb.SetVector("_Position", m_position); - m_mpb.SetVector("_PositionOld", m_positionOld); - m_mpb.SetVector("_Rotation", new Vector4(m_rotation.x, m_rotation.y, m_rotation.z, m_rotation.w)); - m_mpb.SetVector("_RotationOld", new Vector4(m_rotationOld.x, m_rotationOld.y, m_rotationOld.z, m_rotationOld.w)); - m_mpb.SetVector("_Scale", m_scale); - m_mpb.SetVector("_ScaleOld", m_scaleOld); + if (m_applyTransform) + { + m_mpb.SetVector("_Position", m_position); + m_mpb.SetVector("_PositionOld", m_positionOld); + m_mpb.SetVector("_Rotation", new Vector4(m_rotation.x, m_rotation.y, m_rotation.z, m_rotation.w)); + m_mpb.SetVector("_RotationOld", new Vector4(m_rotationOld.x, m_rotationOld.y, m_rotationOld.z, m_rotationOld.w)); + m_mpb.SetVector("_Scale", m_scale); + m_mpb.SetVector("_ScaleOld", m_scaleOld); + } + else + { + m_mpb.SetVector("_Position", Vector3.zero); + m_mpb.SetVector("_PositionOld", Vector3.zero); + m_mpb.SetVector("_Rotation", new Vector4(0, 0, 0, 1)); + m_mpb.SetVector("_RotationOld", new Vector4(0, 0, 0, 1)); + m_mpb.SetVector("_Scale", Vector3.one); + m_mpb.SetVector("_ScaleOld", Vector3.one); + } m_mpb.SetFloat("_PointSize", m_pointSize); m_mpb.SetBuffer("_AlembicPoints", m_cbPoints); if (abcHasIDs)