BITFALL/Assets/BITKit/Unity/Scripts/Location/LocationAdditiveElement.cs

57 lines
1.3 KiB
C#
Raw Normal View History

2023-09-01 14:33:54 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
public class LocationAdditiveElement : MonoBehaviour
{
2023-12-03 17:35:43 +08:00
[SerializeField] private bool useLateUpdate;
2023-09-01 14:33:54 +08:00
[SerializeField] private LocationAdditive locationAdditive;
2023-10-31 18:07:15 +08:00
[SerializeField] private Vector3 positionWeight = Vector3.one;
[SerializeField] private Vector3 eulerWeight = Vector3.one;
private Transform Transform;
private void Start()
{
Transform = transform;
}
2023-09-01 14:33:54 +08:00
private void Update()
2023-12-03 17:35:43 +08:00
{
if (useLateUpdate) return;
Tick();
}
private void LateUpdate()
{
if (!useLateUpdate) return;
Tick();
}
private void Tick()
2023-09-01 14:33:54 +08:00
{
2023-10-31 18:07:15 +08:00
var localPosition = Transform.localPosition;
var localEulerAngles = Transform.localEulerAngles;
//locationAdditive.AddPosition(transform.localPosition);
//locationAdditive.AddEuler(transform.localEulerAngles);
locationAdditive.AddPosition(
new Vector3
{
x = localPosition.x * positionWeight.x,
y = localPosition.y * positionWeight.y,
z = localPosition.z * positionWeight.z
});
locationAdditive.AddEuler(
new Vector3
{
x = localEulerAngles.x * eulerWeight.x,
y = localEulerAngles.y * eulerWeight.y,
z = localEulerAngles.z * eulerWeight.z
});
2023-09-01 14:33:54 +08:00
}
}
}