public override void OnImportAsset(ImportAssetEventArgs args) { var fileName = System.IO.Path.GetFileNameWithoutExtension(args.AssetSourcePath); var go = new GameObject(fileName); var usdStream = go.AddComponent <UsdStream>(); usdStream.importSettings = new usdi.ImportSettings() { interpolation = m_importSettings.interpolation, normalCalculation = m_importSettings.normalCalculation, tangentCalculation = m_importSettings.tangentCalculation, maxBoneWeights = m_importSettings.maxBoneWeights, scale = m_importSettings.scale, loadAllPayloads = true, triangulate = true, swapHandedness = m_importSettings.swapHandedness, swapFaces = m_importSettings.swapFaces, splitMesh = true, doubleBuffering = true, }; usdStream.directVBUpdate = m_directVBUpdate; usdStream.forceSingleThread = m_forceSingleThread; usdStream.timeUnit = m_timeUnit; usdStream.playTime = m_time; usdStream.LoadImmediate(args.AssetSourcePath); var material = new Material(Shader.Find("Standard")) { }; material.name = "Material_0"; args.AddSubAsset("Default Material", material); _subObjects = new SortedDictionary <int, UnityEngine.Object>(); CollectSubAssets(go.transform, args, material); int i = 0; foreach (var m in _subObjects) { if (String.IsNullOrEmpty(m.Value.name) || m.Value.name.IndexOf("<dyn>") == 0) { m.Value.name = fileName + "_" + m.Value.GetType().Name + "_" + (++i); } args.AddSubAsset(m.Value.name, m.Value); } if (m_importMode == UsdImportMode.StripUSD) { usdStream.usdiDetachUsdComponents(); } args.SetMainAsset(fileName, go); }
public override void OnImportAsset(ImportAssetEventArgs args) { m_ImportSettings.m_pathToAbc = args.AssetSourcePath; var mainObject = AlembicImportTasker.Import(m_importMode, m_ImportSettings, m_diagSettings, (stream, mainGO, streamDescr) => { GenerateSubAssets(args, mainGO, stream); if (streamDescr != null) { args.AddSubAsset(mainGO.name, streamDescr); } }); args.SetMainAsset(mainObject.name, mainObject); }