IP on implementing ImportProcessor. PrimMap and Geometry work, IP on UsdPath
ADD
package/com.unity.formats.usd/Runtime/Scripts/IO/ImportProcessor.meta
+fileFormatVersion: 2
+guid: 486e7a15a5b8a244fa4d1d7528ff756e
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:

ADD
package/com.unity.formats.usd/Runtime/Scripts/IO/ImportProcessor/CombineMeshes.cs.meta
+fileFormatVersion: 2
+guid: eb13fa709dbfbd548b745a46a99e442e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:

ADD
package/com.unity.formats.usd/Runtime/Scripts/IO/ImportProcessor/ImportProcessor.cs.meta
+fileFormatVersion: 2
+guid: 072090583bba1ac47aba500294914c30
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:

ADD
package/com.unity.formats.usd/Runtime/Scripts/IO/ImportProcessor/RegexImportProcessor.cs
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System.Text.RegularExpressions;
+using pxr;
+
+//possibly move this to Examples
+namespace Unity.Formats.USD
+{
+ public abstract class RegexImportProcessor : MonoBehaviour
+ {
+
+ public enum ECompareAgainst { UsdName, UsdPath }
+ public ECompareAgainst compareAgainst;
+
+ public enum EMatchType { Wildcard, Regex }
+ public EMatchType matchType;
+
+ public bool isNot = false;
+
+ public string expression = "*";
+ private Regex m_regex;
+
+ protected bool IsMatch(SdfPath sdfPath)
+ {
+ string test = compareAgainst == ECompareAgainst.UsdName ? sdfPath.GetName() : sdfPath.ToString();
+ return isNot ? ! m_regex.IsMatch(test) : m_regex.IsMatch(test);
+ }
+
+ protected void InitRegex()
+ {
+ switch (matchType)
+ {
+ case EMatchType.Wildcard:
+ m_regex = new Regex(WildcardToRegex(expression));
+ break;
+ case EMatchType.Regex:
+ m_regex = new Regex(expression);
+ break;
+ }
+ }
+
+ public static string WildcardToRegex(string pattern)
+ {
+ return "^" + Regex.Escape(pattern).
+ Replace("\\*", ".*").
+ Replace("\\?", ".") + "$";
+ }
+ }
+}

ADD
package/com.unity.formats.usd/Runtime/Scripts/IO/ImportProcessor/RegexImportProcessor.cs.meta
+fileFormatVersion: 2
+guid: 2b8f80f88bd381245a8682e76f675299
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:

ADD
package/com.unity.formats.usd/Runtime/Scripts/IO/ImportProcessor/SetHideFlags.cs.meta
+fileFormatVersion: 2
+guid: bef49abbaed129443bd8dc351c0cb266
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:

MODIFY
package/com.unity.formats.usd/Runtime/Scripts/IO/Scene/SceneImporter.cs
package/com.unity.formats.usd/Runtime/Scripts/IO/Scene/SceneImporter.cs
@@ -342,6 +342,11 @@ namespace Unity.Formats.USD {
if (AfterBuildPrimMap != null) {
AfterBuildPrimMap(primMap, scene, usdPrimRoot, root, importOptions);
}
+
+ foreach( var processor in root.GetComponents<IImportProcessPrimMap>())
+ {
+ processor.ProcessPrimMap(primMap);
+ }
Profiler.EndSample();
if (ShouldYield(targetTime, timer)) { yield return null; ResetTimer(timer); }
@@ -936,6 +941,11 @@ namespace Unity.Formats.USD {
if (AfterImport != null) {
AfterImport(primMap, scene, usdPrimRoot, root, importOptions);
}
+ Debug.LogError("IImportProcessGeometry");
+ foreach( var processor in root.GetComponents<IImportProcessGeometry>())
+ {
+ processor.ProcessGeometry(primMap);
+ }
Profiler.EndSample();
}

IP on implementing ImportProcessor. PrimMap and Geometry work, IP on UsdPath