// Main editor window
public void OnGUI()
{
if (AnimationMode.InAnimationMode())
{
AnimationMode.StopAnimationMode();
}
// Wait for user to select a GameObject
if (bakeObject == null)
{
EditorGUILayout.HelpBox("Please select a GameObject", MessageType.Info);
return;
}
if (buffer == null)
{
buffer = new VertaBuffer();
}
EditorGUILayout.BeginVertical();
EditorGUILayout.LabelField("Selected object: " + bakeObject.name);
modelName = EditorGUILayout.TextField("Model Name", modelName);
animationClip = EditorGUILayout.ObjectField(animationClip, typeof(AnimationClip), false) as AnimationClip;
if (animationClip != null)
{
frameCount = GetFramesCount(animationClip);
EditorGUILayout.LabelField("Frames to bake: " + frameCount);
readyToBake = true;
}
if (GUILayout.Button("Bake mesh animations.") && readyToBake && !EditorApplication.isPlaying)
{
lockSelection = true;
BakeMesh();
lockSelection = false;
}
EditorGUILayout.EndVertical();
}