123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using UnityEngine;
- public class ShowVector : BaseBehaviour
- {
- private void Start()
- {
- this.lastPos = base.transform.position;
- }
- private void Update()
- {
- if (this.type == ShowVector.update.Update)
- {
- this.UpdateVel(Time.smoothDeltaTime);
- }
- }
- private void LateUpdate()
- {
- if (this.type == ShowVector.update.LateUpdate)
- {
- this.UpdateVel(Time.deltaTime);
- }
- }
- private void FixedUpdate()
- {
- if (this.type == ShowVector.update.FixedUpdate)
- {
- this.UpdateVel(Time.fixedDeltaTime);
- }
- }
- private void UpdateVel(float time)
- {
- this.vec = base.transform.position - this.lastPos;
- this.vec /= time;
- this.lastPos = base.transform.position;
- }
- public Vector3 lastPos;
- public Vector3 vec;
- public ShowVector.update type;
- public enum update
- {
- Update,
- LateUpdate,
- FixedUpdate
- }
- }
|