Files
2026-03-04 09:37:33 +08:00

88 lines
2.1 KiB
C#

using System;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Core.PathCore;
using DG.Tweening.Plugins.Options;
using UnityEngine;
using UnityEngine.Scripting;
namespace DG.Tweening
{
public static class DOTweenModuleUtils
{
public static class Physics
{
public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
{
if (options.isRigidbody)
{
((Rigidbody)t.target).rotation = newRot;
}
else
{
trans.rotation = newRot;
}
}
public static bool HasRigidbody2D(Component target)
{
return target.GetComponent<Rigidbody2D>() != null;
}
[Preserve]
public static bool HasRigidbody(Component target)
{
return target.GetComponent<Rigidbody>() != null;
}
[Preserve]
public static TweenerCore<Vector3, Path, PathOptions> CreateDOTweenPathTween(MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode)
{
TweenerCore<Vector3, Path, PathOptions> result = null;
bool flag = false;
if (tweenRigidbody)
{
Rigidbody component = target.GetComponent<Rigidbody>();
if (component != null)
{
flag = true;
result = (isLocal ? component.DOLocalPath(path, duration, pathMode) : component.DOPath(path, duration, pathMode));
}
}
if (!flag && tweenRigidbody)
{
Rigidbody2D component2 = target.GetComponent<Rigidbody2D>();
if (component2 != null)
{
flag = true;
result = (isLocal ? component2.DOLocalPath(path, duration, pathMode) : component2.DOPath(path, duration, pathMode));
}
}
if (!flag)
{
result = (isLocal ? target.transform.DOLocalPath(path, duration, pathMode) : target.transform.DOPath(path, duration, pathMode));
}
return result;
}
}
private static bool _initialized;
[Preserve]
public static void Init()
{
if (!_initialized)
{
_initialized = true;
DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath;
}
}
[Preserve]
private static void Preserver()
{
AppDomain.CurrentDomain.GetAssemblies();
typeof(MonoBehaviour).GetMethod("Stub");
}
}
}