架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -1,13 +1,14 @@
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.UI;
namespace Kamgam.UGUIParticles
{
public partial class ParticleSystemForImage // .Attractor
{
[System.NonSerialized]
protected ParticleSystemForceField _particleSystemForceField;
private RectTransform _attractorRect;
[NonSerialized] protected ParticleSystemForceField _particleSystemForceField;
public ParticleSystemForceField ParticleSystemForceField
{
get
@@ -16,9 +17,8 @@ namespace Kamgam.UGUIParticles
return null;
if (_particleSystemForceField == null)
{
_particleSystemForceField = ParticleSystem.gameObject.GetComponentInChildren<ParticleSystemForceField>(includeInactive: true);
}
_particleSystemForceField =
ParticleSystem.gameObject.GetComponentInChildren<ParticleSystemForceField>(true);
return _particleSystemForceField;
}
@@ -40,7 +40,7 @@ namespace Kamgam.UGUIParticles
return;
// Find or create force field
var forceField = ParticleSystem.gameObject.GetComponentInChildren<ParticleSystemForceField>(includeInactive: true);
var forceField = ParticleSystem.gameObject.GetComponentInChildren<ParticleSystemForceField>(true);
var forces = ParticleSystem.externalForces;
forces.enabled = true;
@@ -62,6 +62,7 @@ namespace Kamgam.UGUIParticles
forceField.multiplyDragByParticleSize = false;
go.SetActive(true);
}
if (forces.influenceCount > 0)
forces.SetInfluence(0, forceField);
else
@@ -80,19 +81,16 @@ namespace Kamgam.UGUIParticles
var forces = ParticleSystem.externalForces;
forces.enabled = false;
var forceField = ParticleSystem.gameObject.GetComponentInChildren<ParticleSystemForceField>(includeInactive: true);
if (forceField != null)
{
forceField.gameObject.SetActive(false);
}
var forceField = ParticleSystem.gameObject.GetComponentInChildren<ParticleSystemForceField>(true);
if (forceField != null) forceField.gameObject.SetActive(false);
}
RectTransform _attractorRect;
/// <summary>
///
/// </summary>
/// <param name="originRelativeToBottomLeft">The origin of the particles relative to the bottom left of the ParticleImage rect.</param>
/// <param name="originRelativeToBottomLeft">
/// The origin of the particles relative to the bottom left of the ParticleImage
/// rect.
/// </param>
/// <param name="width"></param>
/// <param name="height"></param>
public void UpdateAttractorPosition(Vector3 originRelativeToBottomLeft, float width, float height)
@@ -102,12 +100,11 @@ namespace Kamgam.UGUIParticles
DisableAttractor();
return;
}
else if(UseAttractor && Attractor && !ParticleSystemForceField.gameObject.activeSelf)
{
EnableAttractor();
}
if (!UseAttractor || ParticleImage == null || ParticleSystem == null || ParticleSystemForceField == null || Attractor == null)
if (UseAttractor && Attractor && !ParticleSystemForceField.gameObject.activeSelf) EnableAttractor();
if (!UseAttractor || ParticleImage == null || ParticleSystem == null || ParticleSystemForceField == null ||
Attractor == null)
return;
if (_attractorRect != Attractor)
@@ -120,24 +117,23 @@ namespace Kamgam.UGUIParticles
Vector3 attractorDeltaToBottomLeft;
if (_attractorRect != null)
{
attractorDeltaToBottomLeft = ParticleImage.WorldSpaceToUISpace(_attractorRect.TransformPoint(_attractorRect.rect.center), worldPosFromRect: true, ParticleImage.RectTransform, ParticleImage.GetRenderMode());
}
attractorDeltaToBottomLeft = ParticleImage.WorldSpaceToUISpace(
_attractorRect.TransformPoint(_attractorRect.rect.center), true, ParticleImage.RectTransform,
ParticleImage.GetRenderMode());
else
{
attractorDeltaToBottomLeft = ParticleImage.WorldSpaceToUISpace(Attractor, ParticleImage.RectTransform, ParticleImage.GetRenderMode());
}
attractorDeltaToBottomLeft = ParticleImage.WorldSpaceToUISpace(Attractor, ParticleImage.RectTransform,
ParticleImage.GetRenderMode());
Vector3 pixelsPerUnitScaled = new Vector3(
var pixelsPerUnitScaled = new Vector3(
PixelsPerUnit * ParticleImage.transform.lossyScale.x,
PixelsPerUnit * ParticleImage.transform.lossyScale.y,
PixelsPerUnit * ParticleImage.transform.lossyScale.z
);
Vector3 deltaInWorldSpace = (attractorDeltaToBottomLeft - originRelativeToBottomLeft);
var deltaInWorldSpace = attractorDeltaToBottomLeft - originRelativeToBottomLeft;
deltaInWorldSpace.x /= pixelsPerUnitScaled.x;
deltaInWorldSpace.y /= pixelsPerUnitScaled.y;
deltaInWorldSpace.z /= pixelsPerUnitScaled.z;
ParticleSystemForceField.gameObject.transform.localPosition = deltaInWorldSpace;
}
}
}
}