Jan
1
2014

Get Custom Properties from 3dsMax FBX model

Maybe not from the fbx file itself (?), but each object can have custom properties, and Unity can read them on import.

Exporting FBX from 3ds Max with Custom Properties

– Right click on the object
– Select Object Properties

object_properties_1

– Type custom properties to “User Defined” tab (it seems to be single string text area, not line by line)
– For example to make it useful,  add some delimiter to your data: myvalue|anothervalue|somethingelse|…, then split the string in Unity.
object_properties_custom_2

– Export FBX normally for Unity

(no image)

Using OnPostprocessGameObjectWithUserProperties() to read those custom properties

– Create new C# script : FBXCustomProperties.cs
– Now select your fbx file from unity project window, right click on it, ReImport
– In the console window you should see your custom properties printed out

using UnityEditor;
using UnityEngine;
using System.Collections;

public class FBXCustomProperties : AssetPostprocessor
{
void OnPostprocessGameObjectWithUserProperties (GameObject go, string[] names, System.Object[] values)
{
for (int i = 0; i < names.Length; i++)
{
string propertyName = names[i];
object propertyValue = values[i];
Debug.Log("Propname: " + propertyName + " value: " +propertyValue);
}
}
}

References:
– Original idea is from this Unity forum topic+video about Maya FBX custom attributes


1 Comment + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch Instagram

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.