- Home /
How can i connect imported custom animation data to an object.renderer in unity?
Basically I have an object in maya with animated visibility. i've connected this visibility to a custom attribute so i can read that attribute in unity. i know i need to make a custom import process to get that custom attribute data, i just don't know how to hook it up.
looking at a previous (old) question, http://answers.unity3d.com/questions/1040068/custom-export-and-import-fbx-data.html, i can use that code to get the 'raw_data'. i am not sure if that raw_data is the animation curve or if it is a single frame value on import. i assume that the raw_data line needs to be modified so it's not a string, but an animation curve or array of values/keyframes from the custom attr...
raw_data = modelImporter.clipAnimations.meta_key (?)
at that point, i'd want to connect that animation curve to the object's material("_Alpha"), or whatever equivalent it would be for hiding/unhiding an object during playback.
can someone give me some hints on where to go here?
sample code...
public class AssetImport : AssetPostprocessor
{
void OnPostprocessGameObjectWithUserProperties(GameObject incomingGameObject, string[] incomingPropertyNames, System.Object[] incomingValues)
{
var thisModelImporter = this.assetImporter as ModelImporter;
var meta_key = "legVis";
if (incomingPropertyNames.Contains(meta_key))
{
string raw_data = (string)incomingValues[Array.IndexOf(incomingPropetyNames, meta_key)];
incomingGameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", incomingValues);
}
}
}
Your answer
Follow this Question
Related Questions
Is there an easy way to import fbx files runtime? 2 Answers
TextureImporter to Sprite 1 Answer
ImportFBX error resulting in meshes missing 0 Answers
3d max importing problems 0 Answers