public override void OnInspectorGUI() { DrawPropertiesExcluding(serializedObject, "m_Script"); AnimationRecorder animRec = (AnimationRecorder)target; EditorGUILayout.LabelField("Recording progress", EditorStyles.boldLabel); if (!animRec.RecordOnStart && !animRec.HoldsRecording && !animRec.IsRecording) { if (GUILayout.Button("Start recording")) { animRec.StartRecording(); } } else if (!animRec.HoldsRecording || animRec.IsRecording) { Rect r = EditorGUILayout.BeginVertical(); EditorGUI.ProgressBar(r, animRec.RecordingProgress, "Recording progress"); GUILayout.Space(20); EditorGUILayout.EndVertical(); Repaint(); } else { EditorGUILayout.LabelField("Recording done!"); if (GUILayout.Button("Save recording")) { SaveRecordingToFile(animRec); } } }
private void Start() { animRecord = gameObject.GetComponent <AnimationRecorder>(); curBody = Player; curCamera = pCamera; Spirit.GetComponent <BoxCollider>().enabled = false; SwitchToPlayerBody(Player); }
private void SaveRecordingToFile(AnimationRecorder animRec) { AnimRecordingFile file = new AnimRecordingFile(animRec.gameObject.name, animRec.RecordingDuration, animRec.Recordings); string json = JsonConvert.SerializeObject(file, Formatting.Indented); string path = EditorUtility.SaveFilePanelInProject("Save animation to json file", ToCamelCase(file.GameObjectName) + "-animRecording", "json", "Please select the location for the animation file."); File.WriteAllText(path, json); }
public void OnAnimation(GameObject go, AnimationType type, string animation, float time = 0f) { ReplayGameObject resObject = World.ActiveObjects.FirstOrDefault(x => x.SourceObject == go); if (resObject == null) { return; } AnimationRecorder.RecordAnimationCall(resObject, type, animation, time); }
public void OnValidate() { if (mStartRecorder) { mStartRecorder = false; if (mRecording) { Debug.LogError("正在录制,无法重新开始录制"); return; } if (mAnimatorObject == null || mRecorderTarget == null) { Debug.LogError("需要指定状态机节点和录制目标"); return; } Animator animator = mAnimatorObject.GetComponent <Animator>(); if (animator == null) { Debug.LogError("状态机节点上找不到Animator"); return; } AnimationRecorder recorder = animator.GetBehaviour <AnimationRecorder>(); if (recorder == null) { Debug.LogError("找不到AnimationRecorder, 需要在要录制的动画上添加该组件"); return; } if (StringUtility.isEmpty(mFilePath) || !FileUtility.isDirExist(mFilePath)) { Debug.LogError("文件路径非法"); return; } if (StringUtility.isEmpty(mFileName)) { Debug.LogError("文件名非法"); return; } if (mRecordeAlpha && mRecorderTarget.GetComponent <Graphic>() == null && mRecorderTarget.GetComponent <Renderer>() == null) { Debug.LogError("录制目标上找不到透明度设置"); } recorder.mPathRecorder = this; animator.enabled = false; animator.enabled = true; } }
void Start() { if (startingWeapon != null) { PickupGun(startingWeapon); } if (isPlayer) { lockMovement = false; } ai = gameObject.GetComponent <EnemyAI>(); animRec = gameObject.GetComponent <AnimationRecorder>(); playLook = myCamera.GetComponent <PlayerLook>(); curHealth = maxHealth; }