Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by TreasureMap · Oct 23, 2014 at 03:01 PM · importfbxpropertiesuser

What is the correct way to set FBX user properties for import in Unity ?

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[i];
             object propertyValue = values[i];
 
             Debug.Log("Propname: " + propertyName + " value: " +propertyValue);
         }
     }






Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TreasureMap · Oct 24, 2014 at 04:54 AM 0
Share

As it turns out, I didn't make a mistake. This IS the correct way to programmatically create and set FBX user properties. The problem is that Unity does not support 'String Lists' (FbxStringListDT) as a user property. But it supports bool, float, int, vector just fine.

By the way, in Unity, does anyone know what the full supported list of Fbx user properties is ?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by TreasureMap · Oct 24, 2014 at 06:57 AM

I seem to have found the culprit.

I tried building the Fbx SDK sample "UserProperties" which creates a simple fbx scene (cube, pyramid), adds user properties, then exports it as an fbx file.

UserProperties Sample Code:

 void CreateUserProperties(FbxNode *pNode) 
 {
     // Now we create the user properties 
     FbxProperty p1 = FbxProperty::Create(pNode, FbxBoolDT, "MyBooleanProperty", "My Bool");
     FbxProperty p2 = FbxProperty::Create(pNode, FbxFloatDT, "MyRealProperty", "My floating point number");
     FbxProperty p3 = FbxProperty::Create(pNode, FbxColor3DT, "MyColorProperty", "My Color");
     FbxProperty p4 = FbxProperty::Create(pNode, FbxIntDT, "MyInteger", "");
     FbxProperty p5 = FbxProperty::Create(pNode, FbxDouble4DT, "MyVector", "");
     FbxProperty p6 = FbxProperty::Create(pNode, FbxStringListDT, "MyList", "");
 /* 
 NOTE: The properties labels exists only while the property object is in memory.
 The label is not saved in the FBX file. When loading properties from the FBX file
 it will take the same value as the property name.
 */

 // we now fill the properties. All the properties are user properties so we set the
 // correct flag
 p1.ModifyFlag(FbxPropertyAttr::eUserDefined, true);
 p2.ModifyFlag(FbxPropertyAttr::eUserDefined, true);
 p3.ModifyFlag(FbxPropertyAttr::eUserDefined, true);
 p4.ModifyFlag(FbxPropertyAttr::eUserDefined, true);
 p5.ModifyFlag(FbxPropertyAttr::eUserDefined, true);
 p6.ModifyFlag(FbxPropertyAttr::eUserDefined, true);

 // let's make MyColorProperty, MyVector and MyList animatables
 p3.ModifyFlag(FbxPropertyAttr::eAnimatable, true);
 p5.ModifyFlag(FbxPropertyAttr::eAnimatable, true);
 p6.ModifyFlag(FbxPropertyAttr::eAnimatable, true);

 // we set the default values
 FbxColor lRed(1.0, 0.0, 0.0);
 p1.Set(false);
 p2.Set(3.33);
 p3.Set(lRed);
 p4.Set(11);
 p5.Set(FbxDouble3(-1.1, 2.2, -3.3));
 p6.Set(2);

 // and some limits
 p4.SetLimits(-5.0, 9.0);
 p5.SetLimits(0.0, 2.1);

 // add elements to the list
 p6.AddEnumValue("one");
 p6.AddEnumValue("two");
 p6.AddEnumValue("three");
 p6.AddEnumValue("Four");
 p6.InsertEnumValue(0, "zero");

}

When I imported the sample's fbx file into Unity, every property in the sample that was set got logged in the 'OnPostprocessGameObjectWithUserProperties' method EXCEPT FOR ONE!.

The Fbx StringList property. It's apparently not supported by Unity as a user property.

This was the property I was trying to use in my plugin. I will have to use a different property scheme.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Blender 2.62 FBX not importing 2 Answers

Unity reading animations incorrect when constraints used 0 Answers

[3DS Max] Imported model scale issue with Unity 5 5 Answers

Blender import to Unity has metallic shading, black spots when rigging is enabled 1 Answer

How can a USDZ be imported? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges