refactor: apply refactor
parent
5dab4f21c7
commit
b45dc77312
|
@ -1,3 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
using UnityEditor.Overlays;
|
||||
#else
|
||||
|
@ -8,17 +16,6 @@ using UnityEditor.SceneManagement;
|
|||
#elif UNITY_2018_3_OR_NEWER
|
||||
using UnityEditor.Experimental.SceneManagement;
|
||||
#endif
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Coffee.UIParticleExtensions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
|
@ -29,9 +26,9 @@ namespace Coffee.UIExtensions
|
|||
#if UNITY_2021_2_OR_NEWER
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
[Overlay(typeof(SceneView), "Scene View/UI Particles", "UI Particles", true,
|
||||
defaultDockPosition = DockPosition.Bottom,
|
||||
defaultDockZone = DockZone.Floating,
|
||||
defaultLayout = Layout.Panel)]
|
||||
defaultDockPosition = DockPosition.Bottom,
|
||||
defaultDockZone = DockZone.Floating,
|
||||
defaultLayout = Layout.Panel)]
|
||||
#else
|
||||
[Overlay(typeof(SceneView), "Scene View/UI Particles", "UI Particles", true)]
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
|
@ -19,10 +19,7 @@ namespace Coffee.UIExtensions
|
|||
[SerializeField] private ShaderPropertyType m_Type = ShaderPropertyType.Vector;
|
||||
public int id { get; private set; }
|
||||
|
||||
public ShaderPropertyType type
|
||||
{
|
||||
get { return m_Type; }
|
||||
}
|
||||
public ShaderPropertyType type => m_Type;
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIParticleExtensions
|
||||
|
|
|
@ -21,6 +21,13 @@ namespace Coffee.UIExtensions
|
|||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
public class UIParticle : MaskableGraphic, ISerializationCallbackReceiver
|
||||
{
|
||||
public enum AutoScalingMode
|
||||
{
|
||||
None,
|
||||
UIParticle,
|
||||
Transform
|
||||
}
|
||||
|
||||
public enum MeshSharing
|
||||
{
|
||||
None,
|
||||
|
@ -36,13 +43,6 @@ namespace Coffee.UIExtensions
|
|||
Absolute
|
||||
}
|
||||
|
||||
public enum AutoScalingMode
|
||||
{
|
||||
None,
|
||||
UIParticle,
|
||||
Transform
|
||||
}
|
||||
|
||||
[HideInInspector]
|
||||
[SerializeField]
|
||||
internal bool m_IsTrail;
|
||||
|
@ -113,7 +113,7 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
public override bool raycastTarget
|
||||
{
|
||||
get { return false; }
|
||||
get => false;
|
||||
set { }
|
||||
}
|
||||
|
||||
|
@ -127,8 +127,8 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
public MeshSharing meshSharing
|
||||
{
|
||||
get { return m_MeshSharing; }
|
||||
set { m_MeshSharing = value; }
|
||||
get => m_MeshSharing;
|
||||
set => m_MeshSharing = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -137,7 +137,7 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
public int groupId
|
||||
{
|
||||
get { return _groupId; }
|
||||
get => _groupId;
|
||||
set
|
||||
{
|
||||
if (m_GroupId == value) return;
|
||||
|
@ -151,7 +151,7 @@ namespace Coffee.UIExtensions
|
|||
|
||||
public int groupMaxId
|
||||
{
|
||||
get { return m_GroupMaxId; }
|
||||
get => m_GroupMaxId;
|
||||
set
|
||||
{
|
||||
if (m_GroupMaxId == value) return;
|
||||
|
@ -167,8 +167,8 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
public PositionMode positionMode
|
||||
{
|
||||
get { return m_PositionMode; }
|
||||
set { m_PositionMode = value; }
|
||||
get => m_PositionMode;
|
||||
set => m_PositionMode = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -178,8 +178,8 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
public bool absoluteMode
|
||||
{
|
||||
get { return m_PositionMode == PositionMode.Absolute; }
|
||||
set { positionMode = value ? PositionMode.Absolute : PositionMode.Relative; }
|
||||
get => m_PositionMode == PositionMode.Absolute;
|
||||
set => positionMode = value ? PositionMode.Absolute : PositionMode.Relative;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -188,11 +188,8 @@ namespace Coffee.UIExtensions
|
|||
[Obsolete("The autoScaling is now obsolete. Please use the autoScalingMode instead.", false)]
|
||||
public bool autoScaling
|
||||
{
|
||||
get { return m_AutoScalingMode != AutoScalingMode.None; }
|
||||
set
|
||||
{
|
||||
autoScalingMode = value ? AutoScalingMode.Transform : AutoScalingMode.None;
|
||||
}
|
||||
get => m_AutoScalingMode != AutoScalingMode.None;
|
||||
set => autoScalingMode = value ? AutoScalingMode.Transform : AutoScalingMode.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -202,7 +199,7 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
public AutoScalingMode autoScalingMode
|
||||
{
|
||||
get { return m_AutoScalingMode; }
|
||||
get => m_AutoScalingMode;
|
||||
set
|
||||
{
|
||||
if (m_AutoScalingMode == value) return;
|
||||
|
@ -211,49 +208,31 @@ namespace Coffee.UIExtensions
|
|||
}
|
||||
}
|
||||
|
||||
internal bool useMeshSharing
|
||||
{
|
||||
get { return m_MeshSharing != MeshSharing.None; }
|
||||
}
|
||||
internal bool useMeshSharing => m_MeshSharing != MeshSharing.None;
|
||||
|
||||
internal bool isPrimary
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MeshSharing == MeshSharing.Primary
|
||||
|| m_MeshSharing == MeshSharing.PrimarySimulator;
|
||||
}
|
||||
}
|
||||
internal bool isPrimary =>
|
||||
m_MeshSharing == MeshSharing.Primary
|
||||
|| m_MeshSharing == MeshSharing.PrimarySimulator;
|
||||
|
||||
internal bool canSimulate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MeshSharing == MeshSharing.None
|
||||
|| m_MeshSharing == MeshSharing.Auto
|
||||
|| m_MeshSharing == MeshSharing.Primary
|
||||
|| m_MeshSharing == MeshSharing.PrimarySimulator;
|
||||
}
|
||||
}
|
||||
internal bool canSimulate =>
|
||||
m_MeshSharing == MeshSharing.None
|
||||
|| m_MeshSharing == MeshSharing.Auto
|
||||
|| m_MeshSharing == MeshSharing.Primary
|
||||
|| m_MeshSharing == MeshSharing.PrimarySimulator;
|
||||
|
||||
internal bool canRender
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MeshSharing == MeshSharing.None
|
||||
|| m_MeshSharing == MeshSharing.Auto
|
||||
|| m_MeshSharing == MeshSharing.Primary
|
||||
|| m_MeshSharing == MeshSharing.Replica;
|
||||
}
|
||||
}
|
||||
internal bool canRender =>
|
||||
m_MeshSharing == MeshSharing.None
|
||||
|| m_MeshSharing == MeshSharing.Auto
|
||||
|| m_MeshSharing == MeshSharing.Primary
|
||||
|| m_MeshSharing == MeshSharing.Replica;
|
||||
|
||||
/// <summary>
|
||||
/// Particle effect scale.
|
||||
/// </summary>
|
||||
public float scale
|
||||
{
|
||||
get { return m_Scale3D.x; }
|
||||
set { m_Scale3D = new Vector3(value, value, value); }
|
||||
get => m_Scale3D.x;
|
||||
set => m_Scale3D = new Vector3(value, value, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -261,22 +240,18 @@ namespace Coffee.UIExtensions
|
|||
/// </summary>
|
||||
public Vector3 scale3D
|
||||
{
|
||||
get { return m_Scale3D; }
|
||||
set { m_Scale3D = value; }
|
||||
get => m_Scale3D;
|
||||
set => m_Scale3D = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Particle effect scale.
|
||||
/// </summary>
|
||||
public Vector3 scale3DForCalc
|
||||
{
|
||||
get { return autoScalingMode == AutoScalingMode.UIParticle ? m_Scale3D.GetScaled(canvasScale) : m_Scale3D; }
|
||||
}
|
||||
public Vector3 scale3DForCalc => autoScalingMode == AutoScalingMode.UIParticle
|
||||
? m_Scale3D.GetScaled(canvasScale)
|
||||
: m_Scale3D;
|
||||
|
||||
public List<ParticleSystem> particles
|
||||
{
|
||||
get { return m_Particles; }
|
||||
}
|
||||
public List<ParticleSystem> particles => m_Particles;
|
||||
|
||||
/// <summary>
|
||||
/// Get all base materials to render.
|
||||
|
@ -294,10 +269,7 @@ namespace Coffee.UIExtensions
|
|||
}
|
||||
}
|
||||
|
||||
public override Material materialForRendering
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public override Material materialForRendering => null;
|
||||
|
||||
/// <summary>
|
||||
/// Paused.
|
||||
|
@ -637,7 +609,10 @@ namespace Coffee.UIExtensions
|
|||
// Create ortho-camera.
|
||||
if (!_orthoCamera)
|
||||
{
|
||||
var go = new GameObject("[generated] UIParticleOverlayCamera") { hideFlags = HideFlags.HideAndDontSave };
|
||||
var go = new GameObject("[generated] UIParticleOverlayCamera")
|
||||
{
|
||||
hideFlags = HideFlags.HideAndDontSave
|
||||
};
|
||||
go.SetActive(false);
|
||||
go.transform.SetParent(transform, false);
|
||||
_orthoCamera = go.AddComponent<Camera>();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using Coffee.UIParticleExtensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
@ -49,38 +49,38 @@ namespace Coffee.UIExtensions
|
|||
|
||||
public float destinationRadius
|
||||
{
|
||||
get { return m_DestinationRadius; }
|
||||
set { m_DestinationRadius = Mathf.Clamp(value, 0.1f, 10f); }
|
||||
get => m_DestinationRadius;
|
||||
set => m_DestinationRadius = Mathf.Clamp(value, 0.1f, 10f);
|
||||
}
|
||||
|
||||
public float delay
|
||||
{
|
||||
get { return m_DelayRate; }
|
||||
set { m_DelayRate = value; }
|
||||
get => m_DelayRate;
|
||||
set => m_DelayRate = value;
|
||||
}
|
||||
|
||||
public float maxSpeed
|
||||
{
|
||||
get { return m_MaxSpeed; }
|
||||
set { m_MaxSpeed = value; }
|
||||
get => m_MaxSpeed;
|
||||
set => m_MaxSpeed = value;
|
||||
}
|
||||
|
||||
public Movement movement
|
||||
{
|
||||
get { return m_Movement; }
|
||||
set { m_Movement = value; }
|
||||
get => m_Movement;
|
||||
set => m_Movement = value;
|
||||
}
|
||||
|
||||
public UpdateMode updateMode
|
||||
{
|
||||
get { return m_UpdateMode; }
|
||||
set { m_UpdateMode = value; }
|
||||
get => m_UpdateMode;
|
||||
set => m_UpdateMode = value;
|
||||
}
|
||||
|
||||
public UnityEvent onAttracted
|
||||
{
|
||||
get { return m_OnAttracted; }
|
||||
set { m_OnAttracted = value; }
|
||||
get => m_OnAttracted;
|
||||
set => m_OnAttracted = value;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if UNITY_2022_3_0 || UNITY_2022_3_1 || UNITY_2022_3_2 || UNITY_2022_3_3 || UNITY_2022_3_4 || UNITY_2022_3_5 || UNITY_2022_3_6 || UNITY_2022_3_7 || UNITY_2022_3_8 || UNITY_2022_3_9 || UNITY_2022_3_10
|
||||
#if UNITY_2022_3_0 || UNITY_2022_3_1 || UNITY_2022_3_2 || UNITY_2022_3_3 || UNITY_2022_3_4 || UNITY_2022_3_5 || UNITY_2022_3_6 || UNITY_2022_3_7 || UNITY_2022_3_8 || UNITY_2022_3_9 || UNITY_2022_3_10
|
||||
#elif UNITY_2023_1_0 || UNITY_2023_1_1 || UNITY_2023_1_2 || UNITY_2023_1_3 || UNITY_2023_1_4 || UNITY_2023_1_5 || UNITY_2023_1_6 || UNITY_2023_1_7 || UNITY_2023_1_8 || UNITY_2023_1_9
|
||||
#elif UNITY_2023_1_10 || UNITY_2023_1_11 || UNITY_2023_1_12 || UNITY_2023_1_13 || UNITY_2023_1_14 || UNITY_2023_1_15 || UNITY_2023_1_16
|
||||
#elif UNITY_2022_3_OR_NEWER
|
||||
|
@ -36,22 +36,16 @@ namespace Coffee.UIExtensions
|
|||
private Material _modifiedMaterial;
|
||||
private UIParticle _parent;
|
||||
private ParticleSystem _particleSystem;
|
||||
private float _prevCanvasScale;
|
||||
private Vector3 _prevPsPos;
|
||||
private Vector3 _prevScale;
|
||||
private Vector2Int _prevScreenSize;
|
||||
private float _prevCanvasScale;
|
||||
private bool _prewarm;
|
||||
private ParticleSystemRenderer _renderer;
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get { return _isTrail ? null : _particleSystem.GetTextureForSprite(); }
|
||||
}
|
||||
public override Texture mainTexture => _isTrail ? null : _particleSystem.GetTextureForSprite();
|
||||
|
||||
public override bool raycastTarget
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
public override bool raycastTarget => false;
|
||||
|
||||
private Rect rootCanvasRect
|
||||
{
|
||||
|
@ -337,7 +331,8 @@ namespace Coffee.UIExtensions
|
|||
if (_isTrail && _parent.canSimulate && 0 < s_CombineInstances[0].mesh.vertexCount)
|
||||
{
|
||||
#if PS_BAKE_API_V2
|
||||
_renderer.BakeTrailsMesh(s_CombineInstances[0].mesh, bakeCamera, ParticleSystemBakeMeshOptions.BakeRotationAndScale);
|
||||
_renderer.BakeTrailsMesh(s_CombineInstances[0].mesh, bakeCamera,
|
||||
ParticleSystemBakeMeshOptions.BakeRotationAndScale);
|
||||
#else
|
||||
_renderer.BakeTrailsMesh(s_CombineInstances[0].mesh, bakeCamera, true);
|
||||
#endif
|
||||
|
@ -345,7 +340,8 @@ namespace Coffee.UIExtensions
|
|||
else if (_renderer.CanBakeMesh())
|
||||
{
|
||||
#if PS_BAKE_API_V2
|
||||
_renderer.BakeMesh(s_CombineInstances[0].mesh, bakeCamera, ParticleSystemBakeMeshOptions.BakeRotationAndScale);
|
||||
_renderer.BakeMesh(s_CombineInstances[0].mesh, bakeCamera,
|
||||
ParticleSystemBakeMeshOptions.BakeRotationAndScale);
|
||||
#else
|
||||
_renderer.BakeMesh(s_CombineInstances[0].mesh, bakeCamera, true);
|
||||
#endif
|
||||
|
@ -416,6 +412,7 @@ namespace Coffee.UIExtensions
|
|||
c.b = c.b.LinearToGamma();
|
||||
s_Colors[i] = c;
|
||||
}
|
||||
|
||||
workerMesh.SetColors(s_Colors);
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
@ -470,7 +467,7 @@ namespace Coffee.UIExtensions
|
|||
SetMaterialDirty();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
UpdateMaterialProperties();
|
||||
if (_parent.useMeshSharing)
|
||||
{
|
||||
|
|
|
@ -11,10 +11,7 @@ namespace Coffee.UIExtensions
|
|||
private static readonly HashSet<int> s_UpdatedGroupIds = new HashSet<int>();
|
||||
private static int s_FrameCount;
|
||||
|
||||
public static int uiParticleCount
|
||||
{
|
||||
get { return s_ActiveParticles.Count; }
|
||||
}
|
||||
public static int uiParticleCount => s_ActiveParticles.Count;
|
||||
|
||||
public static void Register(UIParticle particle)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Coffee.UIExtensions.Demo
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Coffee.UIExtensions.Demo
|
||||
|
|
Loading…
Reference in New Issue