Hello,
I have noticed that Time.frameCount
value is increasing in my Editor script, whereas I am not in Play mode.
In my understanding, Time.frameCount
returns the number of rendered frame, but as I am not in Play mode, I was expecting this value to stay constant. Am I wrong in my thoughts? Or in my code?
Here is my script :
// Custom Editor using SerializedProperties.
// Automatic handling of multi-object editing, undo, and prefab overrides.
[CustomEditor(typeof(ECAAnimRecorder))]
public class ECAAnimRecorderEditor : Editor {
public SerializedProperty propStartFrame;
public SerializedProperty propEndFrame;
private ECAAnimRecorder ecaRecorder;
private string m_sLabel;
void OnEnable()
{
// Setup the SerializedProperties.
propStartFrame = serializedObject.FindProperty("m_iStartingFrame");
propEndFrame = serializedObject.FindProperty("m_iEndingFrame");
m_sLabel = "";
}
public override void OnInspectorGUI () {
ecaRecorder = ((ECAAnimRecorder)this.target);
// Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
serializedObject.Update();
//can't group textfields without having an horizontal spacebar.
EditorGUILayout.PropertyField(propStartFrame, new GUIContent("Start frame"));
EditorGUILayout.PropertyField(propEndFrame, new GUIContent("End frame"));
//add space before the progress bar
EditorGUILayout.Space();
ProgressBar();
// Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
serializedObject.ApplyModifiedProperties();
}
void OnDisable()
{
m_sLabel = "";
}
/// <summary>
/// Displays a progress bar for frame recording.
/// </summary>
private void ProgressBar()
{
float fCurrentFrame = (float)Time.frameCount;
float fStartFrame = (float)propStartFrame.intValue;
float fEndFrame = (float)propEndFrame.intValue;
float fTotalFrame = fEndFrame - fStartFrame;
float fVal = fCurrentFrame / fTotalFrame;
m_sLabel = "Recording " + fCurrentFrame.ToString() + "/" + fTotalFrame.ToString() + " frames...";
Rect r = GUILayoutUtility.GetRect(18, 18, "TextField");
m_sLabel = (fVal >= 1.0f) ? "Recording completed!" : m_sLabel;
EditorGUI.ProgressBar(r, fVal, m_sLabel);
EditorGUILayout.Space();
}
}
Thanks for your help.