AssetPostprocessor.OnPostprocessGameObjectWithUserProperties Manual     Reference     Scripting  
Scripting > Editor Classes > AssetPostprocessor
AssetPostprocessor.OnPostprocessGameObjectWithUserProperties

function OnPostprocessGameObjectWithUserProperties (root : GameObject, propNames : string[], values : object[]) : void

Description

Gets called for each GameObject that had at least one userpropery attached to it in the imported file.

The propNames is a string[] containing all the names of the properties found. The values is an object[] containing all the actual values. These can be of type string, Vector4, bool, string, Color, float, int.

Typical usecase for this feature is reading out "userdata" stored on objects in 3dmax/maya. Based on what is written in the text userdata for an object, you could decide to postprocess your GameObject in different ways. The sample below adds a simple BoxCollider component if the userdata string contains "addboxcollider".

class MyPostprocessor extends AssetPostprocessor {

function OnPostprocessGameObjectWithUserProperties (
go : GameObject,
propNames : String[],
values : System.Object[]
)
{
for (var i : int =0; i!= propNames.Length; i++)
{

var propName : String = propNames[i];
var value : Object = values[i];

Debug.Log("Propname: "+propName+" value: "+values[i]);

if (value.GetType() == String)
{
var s : String = value;
if (s.Contains("addboxcollider")) go.AddComponent(BoxCollider);
}

if (value.GetType() == Vector4)
{
var v : Vector4 = value;
// do something useful.
}

if (value.GetType() == Color)
{
var c : Color = value;
// do something useful.
}

if (value.GetType() == int)
{
var myInt : int = value;
// do something useful.
}

if (value.GetType() == float)
{
var myFloat : float = value;
// do something useful.
}

}
}
}