public override void OnInspectorGUI() { EventAtFrame eaf = (EventAtFrame)target; serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("anim"), true); if (eaf.anim) { GetClip(); if (eaf.clip) { int maxFrame = Mathf.RoundToInt(eaf.clip.frameRate * eaf.clip.length); eaf.frame = EditorGUILayout.IntSlider("Frame", eaf.frame, 0, maxFrame); } EditorGUILayout.PropertyField(serializedObject.FindProperty("removeAfterReached"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("frameReachedEvent"), true); } else { EditorGUILayout.HelpBox("You must have an Animator referenced.", MessageType.Error); } serializedObject.ApplyModifiedProperties(); }
private void GetClip() { EventAtFrame eaf = (EventAtFrame)target; if (!eaf.anim) { return; } AnimationClip[] clips = eaf.anim.runtimeAnimatorController.animationClips; if (clips.Length <= 0) { return; } int index = 0; for (int i = 0; i < clips.Length; i++) { if (clips[i] == eaf.clip) { index = i; } } string[] clipNames = new string[clips.Length]; for (int i = 0; i < clips.Length; i++) { clipNames[i] = clips[i].name; } index = EditorGUILayout.Popup("Clip", index, clipNames); eaf.clip = clips[index]; }