breakpoint
before update unity version
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
@@ -10,12 +14,34 @@ namespace BITKit
|
||||
[SerializeField] private bool useLateUpdate;
|
||||
[SerializeField] private LocationAdditive locationAdditive;
|
||||
[SerializeField] private Vector3 positionWeight = Vector3.one;
|
||||
[SerializeField] private Vector3 eulerWeight = Vector3.one;
|
||||
|
||||
[SerializeReference,SubclassSelector] private IReference autoReference;
|
||||
//[SerializeField] private Vector3 rotationAdditive = Vector3.one;
|
||||
private Transform Transform;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Transform = transform;
|
||||
var components =
|
||||
GetComponentsInParent<LocationAdditive>(true)
|
||||
.SelectMany(x => x.GetComponentsInChildren<LocationAdditive>(true)).Distinct().ToArray();
|
||||
try
|
||||
{
|
||||
if (!locationAdditive)
|
||||
locationAdditive =components
|
||||
.First(x => x.autoReference is not null && x.autoReference.Value.Equals(autoReference.Value))!;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
StringBuilder reportBuilder = new();
|
||||
foreach (var x in components)
|
||||
{
|
||||
reportBuilder.AppendLine(x.autoReference is not null ? $"{x.autoReference.Value}@{x.transform.name}" : x.name);
|
||||
}
|
||||
BIT4Log.Log<LocationAdditiveElement>($"找不到对应的LocationAdditive:{autoReference.Value} \n{reportBuilder}");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -29,27 +55,14 @@ namespace BITKit
|
||||
if (!useLateUpdate) return;
|
||||
Tick();
|
||||
}
|
||||
|
||||
|
||||
private void Tick()
|
||||
{
|
||||
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
|
||||
});
|
||||
|
||||
locationAdditive.AddPosition(Vector3.Scale(localPosition, positionWeight));
|
||||
//locationAdditive.AddRotation(Transform.localRotation * Quaternion.Euler(rotationAdditive));
|
||||
locationAdditive.AddRotation(Transform.localRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user