I have written an FBX extension plugin for Maya that writes custom user property data to the FBX model node. I have also written an AssetPostprocessor script in Unity.
Although the custom FBX property is marked as a user prop, the AssetPostprocessor method “OnPostprocessGameObjectWithUserProperties” does not execute when the FBX file is imported into Unity. The properties are definitely in the FBX file. I have checked it.
Question : What is the correct way to programmatically set FBX user properties so that they will be picked up by Unity’s AssetPostprocessor ?
I have included some sample code below. Please let me know if you can help.
Maya Plugin Code Sample:
void WriteUserProp(FbxNode* pNode){
FbxProperty myProp = FbxProperty::Create(pNode, FbxStringListDT, "MyCustomProp");
myProp.ModifyFlag(FbxPropertyAttr::eUserDefined, true);
myProp.AddEnumValue( "A,B,C" );
myProp.AddEnumValue( "D,E,F" );
myProp.AddEnumValue( "G,H,I" );
}
FBX File Data Sample:
Model: 973885280, "Model::cat:polySurface1", "Mesh" {
Version: 232
Properties70:{
<snip>
P: "MyCustomProp", "stringlist", "", "U",0, "A,B,C~D,E,F~G,H,I"
}
Shading: T
Culling: "CullingOff"
}
AssetPostprocessor Code Sample:
void OnPostprocessGameObjectWithUserProperties(GameObject go, string[] names, System.Object[] values)
{
Debug.Log (this.GetType().ToString() + "::" + MethodInfo.GetCurrentMethod().Name );
//FBX Models Only
if (assetPath.IndexOf (".fbx") == -1)
return;
Debug.Log ("GameObject: " + go.name);
for (int i = 0; i < names.Length; i++)
{
string propertyName = names*;*
_ object propertyValue = values*;*_
* Debug.Log("Propname: " + propertyName + " value: " +propertyValue);*
* }*
* }*