1
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
// ReSharper disable InvertIf
|
||||
namespace BITKit
|
||||
{
|
||||
public class LocationAdditive : MonoBehaviour
|
||||
{
|
||||
public Vector3 GlobalPosition { get; private set; }
|
||||
public Vector3 GlobalEuler { get; private set; }
|
||||
public Vector3 GlobalRotation { get; private set; }
|
||||
|
||||
private Vector3 currentPosition;
|
||||
private Vector3 currentEuler;
|
||||
|
||||
private Vector3 globalPosition;
|
||||
private Quaternion globalRotation;
|
||||
public void AddPosition(Vector3 value)
|
||||
{
|
||||
currentPosition += value;
|
||||
@@ -16,18 +25,44 @@ namespace BITKit
|
||||
{
|
||||
currentEuler += value;
|
||||
}
|
||||
public void SetGlobalPosition(Vector3 value)
|
||||
{
|
||||
globalPosition = value;
|
||||
}
|
||||
public void SetGlobalRotation(Quaternion value)
|
||||
{
|
||||
globalRotation = value;
|
||||
}
|
||||
public void LateUpdate()
|
||||
{
|
||||
if (currentEuler.IsDefault() is false)
|
||||
switch (currentEuler,globalRotation)
|
||||
{
|
||||
transform.localEulerAngles = currentEuler;
|
||||
currentEuler = default;
|
||||
case var (euler,rotation) when euler.IsDefault() is false && rotation.IsDefault():
|
||||
transform.localRotation = Quaternion.Euler(euler);
|
||||
break;
|
||||
case var (euler,rotation) when euler.IsDefault() && rotation.IsDefault() is false:
|
||||
transform.rotation = globalRotation = rotation;
|
||||
break;
|
||||
case var (euler,rotation) when euler.IsDefault() is false && rotation.IsDefault() is false:
|
||||
transform.rotation = globalRotation = rotation * Quaternion.Euler(euler);
|
||||
break;
|
||||
}
|
||||
if (currentPosition.IsDefault() is false)
|
||||
|
||||
switch (currentPosition,globalPosition)
|
||||
{
|
||||
transform.localPosition = currentPosition;
|
||||
currentPosition = default;
|
||||
case var (position,global) when position.IsDefault() is false && global.IsDefault():
|
||||
transform.localPosition = position;
|
||||
break;
|
||||
case var (position,global) when position.IsDefault() && global.IsDefault() is false:
|
||||
transform.position =globalPosition= global;
|
||||
break;
|
||||
case var (position,global) when position.IsDefault() is false && global.IsDefault() is false:
|
||||
transform.position = globalPosition = global + position;
|
||||
break;
|
||||
}
|
||||
|
||||
currentEuler = Vector3.zero;
|
||||
currentPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user