Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a keyframe limiter #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,92 +3,103 @@
using System.Collections;

[CustomEditor(typeof(UnityAnimationRecorder))]
public class UnityAnimationRecorderEditor : Editor {
public class UnityAnimationRecorderEditor : Editor
{

// save file path
SerializedProperty savePath;
SerializedProperty fileName;
// save file path
SerializedProperty savePath;
SerializedProperty fileName;

SerializedProperty startRecordKey;
SerializedProperty stopRecordKey;
SerializedProperty startRecordKey;
SerializedProperty stopRecordKey;

// options
SerializedProperty showLogGUI;
SerializedProperty recordLimitedFrames;
SerializedProperty recordFrames;
// options
SerializedProperty showLogGUI;
SerializedProperty recordLimitedFrames;
SerializedProperty recordFrames;

SerializedProperty changeTimeScale;
SerializedProperty timeScaleOnStart;
SerializedProperty timeScaleOnRecord;
SerializedProperty changeTimeScale;
SerializedProperty timeScaleOnStart;
SerializedProperty timeScaleOnRecord;
SerializedProperty frameDelta;


void OnEnable () {
void OnEnable()
{

savePath = serializedObject.FindProperty ("savePath");
fileName = serializedObject.FindProperty ("fileName");
savePath = serializedObject.FindProperty("savePath");
fileName = serializedObject.FindProperty("fileName");

startRecordKey = serializedObject.FindProperty ("startRecordKey");
stopRecordKey = serializedObject.FindProperty ("stopRecordKey");
startRecordKey = serializedObject.FindProperty("startRecordKey");
stopRecordKey = serializedObject.FindProperty("stopRecordKey");

showLogGUI = serializedObject.FindProperty ("showLogGUI");
recordLimitedFrames = serializedObject.FindProperty ("recordLimitedFrames");
recordFrames = serializedObject.FindProperty ("recordFrames");
showLogGUI = serializedObject.FindProperty("showLogGUI");
recordLimitedFrames = serializedObject.FindProperty("recordLimitedFrames");
recordFrames = serializedObject.FindProperty("recordFrames");

changeTimeScale = serializedObject.FindProperty ("changeTimeScale");
timeScaleOnStart = serializedObject.FindProperty ("timeScaleOnStart");
timeScaleOnRecord = serializedObject.FindProperty ("timeScaleOnRecord");
}
changeTimeScale = serializedObject.FindProperty("changeTimeScale");
timeScaleOnStart = serializedObject.FindProperty("timeScaleOnStart");
timeScaleOnRecord = serializedObject.FindProperty("timeScaleOnRecord");
frameDelta = serializedObject.FindProperty("frameDelta");
}

public override void OnInspectorGUI () {
serializedObject.Update ();
public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.LabelField ("== Path Settings ==");
EditorGUILayout.LabelField("== Path Settings ==");

if (GUILayout.Button ("Set Save Path")) {
string defaultName = serializedObject.targetObject.name + "-Animation";
string targetPath = EditorUtility.SaveFilePanelInProject ("Save Anim File To ..", defaultName, "", "please select a folder and enter the file name");
if (GUILayout.Button("Set Save Path"))
{
string defaultName = serializedObject.targetObject.name + "-Animation.anim";
string targetPath = EditorUtility.SaveFilePanelInProject("Save Anim File To ..", defaultName, "anim", "please select a folder and enter the file name");

int lastIndex = targetPath.LastIndexOf ("/");
savePath.stringValue = targetPath.Substring (0, lastIndex + 1);
string toFileName = targetPath.Substring (lastIndex + 1);
int lastIndex = targetPath.LastIndexOf("/");
savePath.stringValue = targetPath.Substring(0, lastIndex + 1);
string toFileName = targetPath.Substring(lastIndex + 1);

fileName.stringValue = toFileName;
}
EditorGUILayout.PropertyField (savePath);
EditorGUILayout.PropertyField (fileName);
if (toFileName.IndexOf(".anim") < 0)
toFileName += ".anim";

fileName.stringValue = toFileName;
}
EditorGUILayout.PropertyField(savePath);
EditorGUILayout.PropertyField(fileName);

EditorGUILayout.Space ();

// keys setting
EditorGUILayout.LabelField( "== Control Keys ==" );
EditorGUILayout.PropertyField (startRecordKey);
EditorGUILayout.PropertyField (stopRecordKey);
EditorGUILayout.Space();

EditorGUILayout.Space ();
// keys setting
EditorGUILayout.LabelField("== Control Keys ==");
EditorGUILayout.PropertyField(startRecordKey);
EditorGUILayout.PropertyField(stopRecordKey);

// Other Settings
EditorGUILayout.LabelField( "== Other Settings ==" );
bool timeScaleOption = EditorGUILayout.Toggle ( "Change Time Scale", changeTimeScale.boolValue);
changeTimeScale.boolValue = timeScaleOption;
EditorGUILayout.Space();

if (timeScaleOption) {
timeScaleOnStart.floatValue = EditorGUILayout.FloatField ("TimeScaleOnStart", timeScaleOnStart.floatValue);
timeScaleOnRecord.floatValue = EditorGUILayout.FloatField ("TimeScaleOnRecord", timeScaleOnRecord.floatValue);
}
// Other Settings
EditorGUILayout.LabelField("== Other Settings ==");
bool timeScaleOption = EditorGUILayout.Toggle("Change Time Scale", changeTimeScale.boolValue);
changeTimeScale.boolValue = timeScaleOption;

// gui log message
showLogGUI.boolValue = EditorGUILayout.Toggle ("Show Debug On GUI", showLogGUI.boolValue);
if (timeScaleOption)
{
timeScaleOnStart.floatValue = EditorGUILayout.FloatField("TimeScaleOnStart", timeScaleOnStart.floatValue);
timeScaleOnRecord.floatValue = EditorGUILayout.FloatField("TimeScaleOnRecord", timeScaleOnRecord.floatValue);
}

// recording frames setting
recordLimitedFrames.boolValue = EditorGUILayout.Toggle( "Record Limited Frames", recordLimitedFrames.boolValue );
// gui log message
showLogGUI.boolValue = EditorGUILayout.Toggle("Show Debug On GUI", showLogGUI.boolValue);

if (recordLimitedFrames.boolValue)
EditorGUILayout.PropertyField (recordFrames);
// recording frames setting
recordLimitedFrames.boolValue = EditorGUILayout.Toggle("Record Limited Frames", recordLimitedFrames.boolValue);

serializedObject.ApplyModifiedProperties ();
if (recordLimitedFrames.boolValue)
EditorGUILayout.PropertyField(recordFrames);

//DrawDefaultInspector ();
}
frameDelta.floatValue = 1.0f / EditorGUILayout.FloatField("Frame Rate", 1.0f / frameDelta.floatValue);

serializedObject.ApplyModifiedProperties();

//DrawDefaultInspector ();
}
}
Loading