Compare commits

..

6 Commits

Author SHA1 Message Date
mob-sakai
09ccb0d47c update demo 2024-07-18 15:04:41 +09:00
mob-sakai
819de92b20 docs: update readme 2024-07-18 14:24:49 +09:00
mob-sakai
1628290db7 feat: add project settings for UIParticle
- enableLinearToGamma: Enables LinearToGamma during mesh baking
2024-07-18 14:21:07 +09:00
mob-sakai
d33bde10d2 install coffee.internal 2024-07-18 14:21:07 +09:00
mob-sakai
29e30a3f1b feat: UIParticle no longer inherits from MaskableGraphic
BREAKING CHANGE: Some members inherited from MaskableGraphic will no longer be available.
2024-07-18 14:15:55 +09:00
mob-sakai
ae838587cb feat: change the default value of UIParticle.scale from 10 to 1
close #310
2024-07-18 14:15:55 +09:00
27 changed files with 163 additions and 256 deletions

View File

@@ -1,12 +1,12 @@
name: 🔖 Release
run-name: 🔖 Release (${{ github.ref_name }})
on:
workflow_dispatch:
push:
branches:
- release
- release-*
- release-preview
- release-v4
tags-ignore:
- "**"
@@ -50,12 +50,14 @@ jobs:
if [ '${{ steps.release.outputs.new_release_published }}' = 'false' ]; then
echo "No new release published." | tee -a $GITHUB_STEP_SUMMARY
elif [ '${{ github.ref_name }}' = 'release' ]; then
echo "merge_to=develop" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
echo "split_to=main" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
else
channel=$(echo ${{ github.ref_name }} | sed 's/^release-//')
echo "merge_to=develop-${channel}" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
echo "split_to=${channel}" | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
echo "merge_to=develop" | tee -a $GITHUB_OUTPUT
echo "split_to=main" | tee -a $GITHUB_OUTPUT
elif [ '${{ github.ref_name }}' = 'release-preview' ]; then
echo "merge_to=develop-preview" | tee -a $GITHUB_OUTPUT
echo "split_to=preview" | tee -a $GITHUB_OUTPUT
elif [ '${{ github.ref_name }}' = 'release-4.x' ]; then
echo "merge_to=develop-4.x" | tee -a $GITHUB_OUTPUT
echo "split_to=4.x" | tee -a $GITHUB_OUTPUT
fi
merge-to:

View File

@@ -3,13 +3,12 @@
# UNITY_EMAIL: Unity user email to login
# UNITY_PASSWORD: Unity user password to login
name: 🧪 Test
run-name: 🧪 Test (${{ github.ref_name }})
env:
# MINIMUM_VERSION: The minimum version of Unity.
MINIMUM_VERSION: 2019.4
# EXCLUDE_FILTER: The excluded versions of Unity.
EXCLUDE_FILTER: '(2020.2.0|2021.1|2023.3)'
EXCLUDE_FILTER: '(2020.2.0)'
on:
workflow_dispatch:

View File

@@ -80,11 +80,7 @@ namespace Coffee.UIExtensions.Demo
.SelectMany(x => x.GetTypes())
.FirstOrDefault(x => x.Name == typeName);
#if UNITY_2023_2_OR_NEWER
return type == null ? null : FindFirstObjectByType(type);
#else
return type == null ? null : FindObjectOfType(type);
#endif
}
public void SetCanvasWidth(int width)

View File

@@ -12,5 +12,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f22a23b9d98e440478697f4adf30e61c, type: 3}
m_Name: UIParticle
m_EditorClassIdentifier:
m_EnableLinearToGamma: 1
m_HideGeneratedObjects: 1
m_LinearToGamma: 1

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4b9df7b8a4193489299b8f477348ae0c
guid: e8e7744b163af4869b07b8f192c810ed
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

View File

@@ -1,8 +1,9 @@
{
"dependencies": {
"com.unity.ide.rider": "3.0.31",
"com.coffee.development": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/Development",
"com.coffee.nano-monitor": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
"com.unity.ide.rider": "3.0.31",
"com.coffee.sub-asset-editor": "https://github.com/mob-sakai/SubAssetEditor.git",
"com.unity.test-framework": "1.1.33",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.physics": "1.0.0"

View File

@@ -5,7 +5,7 @@
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "4e5f735ccf956ee469b5014ae781068c49a2825d"
"hash": "c51e4514c9ab944915a639433ee52342e55a644e"
},
"com.coffee.nano-monitor": {
"version": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
@@ -14,7 +14,14 @@
"dependencies": {
"com.unity.ugui": "1.0.0"
},
"hash": "4e5f735ccf956ee469b5014ae781068c49a2825d"
"hash": "c51e4514c9ab944915a639433ee52342e55a644e"
},
"com.coffee.sub-asset-editor": {
"version": "https://github.com/mob-sakai/SubAssetEditor.git",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "01464178eec1e4dbe741c11c9baeb94a151c99ee"
},
"com.coffee.ui-particle": {
"version": "file:src",

View File

@@ -1,22 +1,3 @@
# [4.10.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.1...v4.10.0) (2024-09-29)
### Bug Fixes
* component icon is not set ([5ff6ec8](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/5ff6ec815a174de5d3f16d424f1204c60912a8d8))
### Features
* add project settings ([1ce4e31](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/1ce4e31a9681bf1a201d2723c8d97e07ecc16592))
## [4.9.1](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.9.0...v4.9.1) (2024-08-07)
### Bug Fixes
* ParticleSystem trails gain offset on parent canvas change ([2a1cd50](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/2a1cd502b452b5b56edf8bcfe91adf99d1bb5147)), closes [#323](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/323)
# [4.9.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v4.8.1...v4.9.0) (2024-07-18)

View File

@@ -2,19 +2,20 @@ using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.UI;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.UI;
using Coffee.UIParticleInternal;
#if UNITY_2021_2_OR_NEWER
using UnityEditor.Overlays;
#else
using System;
using System.Reflection;
using Coffee.UIParticleInternal;
using Object = UnityEngine.Object;
#endif
#if UNITY_2021_2_OR_NEWER
using UnityEditor.SceneManagement;
@@ -26,7 +27,7 @@ namespace Coffee.UIExtensions
{
[CustomEditor(typeof(UIParticle))]
[CanEditMultipleObjects]
internal class UIParticleEditor : GraphicEditor
internal class UIParticleEditor : Editor
{
//################################
// Constant or Static Members.
@@ -81,10 +82,8 @@ namespace Coffee.UIExtensions
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
private void OnEnable()
{
base.OnEnable();
_maskable = serializedObject.FindProperty("m_Maskable");
_scale3D = serializedObject.FindProperty("m_Scale3D");
_animatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
@@ -437,9 +436,7 @@ namespace Coffee.UIExtensions
{
if (!p || (ignoreCurrent && target == p)) return;
var cr = p.canvasRenderer;
DestroyImmediate(p);
DestroyImmediate(cr);
#if UNITY_2018_3_OR_NEWER
var stage = PrefabStageUtility.GetCurrentPrefabStage();

View File

@@ -11,7 +11,7 @@
[![](https://img.shields.io/github/watchers/mob-sakai/ParticleEffectForUGUI.svg?style=social&label=Watch)](https://github.com/mob-sakai/ParticleEffectForUGUI/subscription)
[![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai)
<< [📝 Description](#-description-) | [📌 Key Features](#-key-features) | [🎮 Demo](#-demo) | [⚙ Installation](#-installation) | [🚀 Usage](#-usage) | [🛠 Development Note](#-development-note) | [🤝 Contributing](#-contributing) >>
<< [📝 Description](#-description-) | [📌 Key Features](#-key-features) | [🎮 Demo](#-demo) | [⚙ Installation](#-installation) | [🔄 Upgrading to 5.x](#-upgrading-from-3x4x-to-5x) | [🚀 Usage](#-usage) | [🛠 Development Note](#-development-note) | [🤝 Contributing](#-contributing) >>
## 📝 Description <!-- omit in toc -->
@@ -27,6 +27,8 @@ You can render, mask, and sort your `ParticleSystems` for UI without the need fo
- [Install via UPM (with Package Manager UI)](#install-via-upm-with-package-manager-ui)
- [Install via UPM (Manually)](#install-via-upm-manually)
- [Install as Embedded Package](#install-as-embedded-package)
- [🔄 Upgrading from 3.x/4.x to 5.x](#-upgrading-from-3x4x-to-5x)
- [Breaking Changes](#breaking-changes)
- [🚀 Usage](#-usage)
- [Component: UIParticle](#component-uiparticle)
- [Basic Usage](#basic-usage)
@@ -34,7 +36,6 @@ You can render, mask, and sort your `ParticleSystems` for UI without the need fo
- [Usage with `Mask` or `RectMask2D` Component](#usage-with-mask-or-rectmask2d-component)
- [Usage with Script](#usage-with-script)
- [Component: UIParticleAttractor](#component-uiparticleattractor)
- [Project Settings](#project-settings)
- [🛠 Development Note](#-development-note)
- [Compares the Baking mesh approach with the conventional approach](#compares-the-baking-mesh-approach-with-the-conventional-approach)
- [Performance test results](#performance-test-results)
@@ -152,6 +153,17 @@ _This package requires **Unity 2018.3 or later**._
<br><br>
## 🔄 Upgrading from 3.x/4.x to 5.x
### Breaking Changes
- The default value of `UIParticle.scale` has been changed from `10` to `1`.
- `UIParticle` no longer inherits from `MaskableGraphic`.
- Add project settings for UIParticle
- enableLinearToGamma: Enables LinearToGamma during mesh baking
<br><br>
## 🚀 Usage
### Component: UIParticle
@@ -257,14 +269,6 @@ uiParticle.Stop();
<br><br>
### Project Settings
![](https://github.com/user-attachments/assets/befc7f34-fb47-4006-831a-eba79fda11ca)
- Click `Edit > Project Settings` to open the Project Settings window and then select `UI > UI Particle` category.
<br><br>
## 🛠 Development Note
### Compares the Baking mesh approach with the conventional approach

View File

@@ -1,125 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.UI;
namespace Coffee.UIParticleInternal
{
/// <summary>
/// Extension methods for Graphic class.
/// </summary>
internal static class GraphicExtensions
{
private static readonly Vector3[] s_WorldCorners = new Vector3[4];
private static readonly Bounds s_ScreenBounds = new Bounds(new Vector3(0.5f, 0.5f, 0.5f), new Vector3(1, 1, 1));
/// <summary>
/// Check if a Graphic component is currently in the screen view.
/// </summary>
public static void GetMaterialsForRendering(this Graphic self, List<Material> result)
{
result.Clear();
if (!self) return;
var cr = self.canvasRenderer;
var count = cr.materialCount;
var popCount = cr.popMaterialCount;
if (result.Capacity < count + popCount)
{
result.Capacity = count + popCount;
}
for (var i = 0; i < count; i++)
{
result.Add(cr.GetMaterial(i));
}
for (var i = 0; i < popCount; i++)
{
result.Add(cr.GetPopMaterial(i));
}
}
/// <summary>
/// Check if a Graphic component is currently in the screen view.
/// </summary>
public static bool IsInScreen(this Graphic self)
{
if (!self || !self.canvas) return false;
if (FrameCache.TryGet(self, nameof(IsInScreen), out bool result))
{
return result;
}
Profiler.BeginSample("(COF)[GraphicExt] IsInScreen");
var cam = self.canvas.renderMode != RenderMode.ScreenSpaceOverlay
? self.canvas.worldCamera
: null;
var min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
var max = new Vector3(float.MinValue, float.MinValue, float.MinValue);
self.rectTransform.GetWorldCorners(s_WorldCorners);
var screenSize = GetScreenSize();
for (var i = 0; i < 4; i++)
{
if (cam)
{
s_WorldCorners[i] = cam.WorldToViewportPoint(s_WorldCorners[i]);
}
else
{
s_WorldCorners[i] = RectTransformUtility.WorldToScreenPoint(null, s_WorldCorners[i]);
s_WorldCorners[i].x /= screenSize.x;
s_WorldCorners[i].y /= screenSize.y;
}
s_WorldCorners[i].z = 0;
min = Vector3.Min(s_WorldCorners[i], min);
max = Vector3.Max(s_WorldCorners[i], max);
}
var bounds = new Bounds(min, Vector3.zero);
bounds.Encapsulate(max);
result = bounds.Intersects(s_ScreenBounds);
FrameCache.Set(self, nameof(IsInScreen), result);
Profiler.EndSample();
return result;
}
/// <summary>
/// Get the actual main texture of a Graphic component.
/// </summary>
public static Texture GetActualMainTexture(this Graphic self)
{
var image = self as Image;
if (image == null) return self.mainTexture;
var sprite = image.overrideSprite;
return sprite ? sprite.GetActualTexture() : self.mainTexture;
}
private static Vector2Int GetScreenSize()
{
#if UNITY_EDITOR
if (!Application.isPlaying && !Camera.current)
{
var res = UnityStats.screenRes.Split('x');
return new Vector2Int(int.Parse(res[0]), int.Parse(res[1]));
}
#endif
return new Vector2Int(Screen.width, Screen.height);
}
public static float GetParentGroupAlpha(this Graphic self)
{
var alpha = self.canvasRenderer.GetAlpha();
if (Mathf.Approximately(alpha, 0)) return 1;
var inheritedAlpha = self.canvasRenderer.GetInheritedAlpha();
return Mathf.Clamp01(inheritedAlpha / alpha);
}
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace Coffee.UIParticleInternal
{
/// <summary>
/// Extension methods for Component class.
/// </summary>
internal static class ListExtensions
{
public static void RemoveAtFast<T>(this List<T> self, int index)
{
if (self == null) return;
var lastIndex = self.Count - 1;
self[index] = self[lastIndex];
self.RemoveAt(lastIndex);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3803b037cd2ed45459dd660072f223dd
guid: 833553390099d40c9b212823f0852c46
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -34,9 +34,9 @@ namespace Coffee.UIParticleInternal
var defaultSettings = GetDefaultSettings(t);
if (!defaultSettings)
{
// When create a new instance, automatically set it as default settings.
defaultSettings = t.GetProperty("instance", flags)
?.GetValue(null, null) as PreloadedProjectSettings;
SetDefaultSettings(defaultSettings);
}
else if (GetPreloadedSettings(t).Length != 1)
{
@@ -73,7 +73,6 @@ namespace Coffee.UIParticleInternal
protected static void SetDefaultSettings(PreloadedProjectSettings asset)
{
if (!asset) return;
var type = asset.GetType();
if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(asset)))
{
@@ -104,6 +103,7 @@ namespace Coffee.UIParticleInternal
}
#endif
public abstract class PreloadedProjectSettings<T> : PreloadedProjectSettings
where T : PreloadedProjectSettings<T>
{

View File

@@ -46,6 +46,7 @@ namespace Coffee.UIParticleInternal
GetFrameCache<T>().Set((key1.GetHashCode(), key2.GetHashCode()), result);
}
/// <summary>
/// Sets a value in the frame cache with a specified key.
/// </summary>

View File

@@ -5,6 +5,7 @@ using Object = UnityEngine.Object;
#if ENABLE_COFFEE_LOGGER
using System.Reflection;
using System.Collections.Generic;
#else
using Conditional = System.Diagnostics.ConditionalAttribute;
#endif
@@ -42,6 +43,7 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@@ -51,6 +53,7 @@ namespace Coffee.UIParticleInternal
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@@ -59,6 +62,7 @@ namespace Coffee.UIParticleInternal
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@@ -76,6 +80,7 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@@ -119,6 +124,7 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@@ -164,6 +170,7 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif
@@ -202,6 +209,7 @@ namespace Coffee.UIParticleInternal
#endif
}
#if !ENABLE_COFFEE_LOGGER
[Conditional(k_DisableSymbol)]
#endif

View File

@@ -55,6 +55,7 @@ namespace Coffee.UIParticleInternal
Profiler.EndSample();
}
/// <summary>
/// Adds or retrieves a cached material based on the hash.
/// </summary>

View File

@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Coffee.UIParticleInternal;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.UI;
using Random = UnityEngine.Random;
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")]
@@ -18,7 +18,7 @@ namespace Coffee.UIExtensions
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
[RequireComponent(typeof(CanvasRenderer))]
public class UIParticle : MaskableGraphic, ISerializationCallbackReceiver
public class UIParticle : UIBehaviour, ISerializationCallbackReceiver
{
public enum AutoScalingMode
{
@@ -60,7 +60,7 @@ namespace Coffee.UIExtensions
[Tooltip("Scale the rendering particles. When the `3D` toggle is enabled, 3D scale (x, y, z) is supported.")]
[SerializeField]
private Vector3 m_Scale3D = new Vector3(10, 10, 10);
private Vector3 m_Scale3D = new Vector3(1, 1, 1);
[Tooltip("If you want to update material properties (e.g. _MainTex_ST, _Color) in AnimationClip, " +
"use this to mark as animatable.")]
@@ -117,20 +117,48 @@ namespace Coffee.UIExtensions
"Change the bake view size.")]
private float m_CustomViewSize = 10;
[SerializeField]
private bool m_Maskable = true;
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
private Camera _bakeCamera;
private Canvas _canvas;
private int _groupId;
private bool _isScaleStored;
private Vector3 _storedScale;
private DrivenRectTransformTracker _tracker;
/// <summary>
/// Should this graphic be considered a target for ray-casting?
/// </summary>
public override bool raycastTarget
public RectTransform rectTransform => transform as RectTransform;
public Canvas canvas
{
get => false;
set { }
get
{
if (_canvas) return _canvas;
var tr = transform;
while (tr && !_canvas)
{
if (tr.TryGetComponent(out _canvas)) return _canvas;
tr = tr.parent;
}
return null;
}
}
/// <summary>
/// Does this graphic allow masking.
/// </summary>
public bool maskable
{
get => m_Maskable;
set
{
if (value == m_Maskable) return;
m_Maskable = value;
UpdateRendererMaterial();
}
}
/// <summary>
@@ -307,15 +335,15 @@ namespace Coffee.UIExtensions
public Vector3 parentScale { get; private set; }
public Vector3 canvasScale { get; private set; }
private Vector3 canvasScale { get; set; }
protected override void OnEnable()
{
_isScaleStored = false;
ResetGroupId();
UIParticleUpdater.Register(this);
RegisterDirtyMaterialCallback(UpdateRendererMaterial);
//
if (0 < particles.Count)
{
RefreshParticles(particles);
@@ -325,7 +353,7 @@ namespace Coffee.UIExtensions
RefreshParticles();
}
base.OnEnable();
UpdateRendererMaterial();
}
/// <summary>
@@ -342,9 +370,15 @@ namespace Coffee.UIExtensions
_isScaleStored = false;
UIParticleUpdater.Unregister(this);
_renderers.ForEach(r => r.Reset());
UnregisterDirtyMaterialCallback(UpdateRendererMaterial);
_canvas = null;
}
base.OnDisable();
/// <summary>
/// Called when the state of the parent Canvas is changed.
/// </summary>
protected override void OnCanvasHierarchyChanged()
{
_canvas = null;
}
/// <summary>
@@ -354,6 +388,14 @@ namespace Coffee.UIExtensions
{
}
/// <summary>
/// This function is called when a direct or indirect parent of the transform of the GameObject has changed.
/// </summary>
protected override void OnTransformParentChanged()
{
_canvas = null;
}
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
}
@@ -646,17 +688,6 @@ namespace Coffee.UIExtensions
: Random.Range(m_GroupId, m_GroupMaxId + 1);
}
protected override void UpdateMaterial()
{
}
/// <summary>
/// Call to update the geometry of the Graphic onto the CanvasRenderer.
/// </summary>
protected override void UpdateGeometry()
{
}
private void UpdateRendererMaterial()
{
for (var i = 0; i < _renderers.Count; i++)
@@ -732,7 +763,7 @@ namespace Coffee.UIExtensions
_bakeCamera.useOcclusionCulling = false;
_bakeCamera.gameObject.SetActive(false);
_bakeCamera.gameObject.hideFlags = UIParticleProjectSettings.globalHideFlags;
_bakeCamera.gameObject.hideFlags = HideFlags.HideAndDontSave;
return _bakeCamera;
}

View File

@@ -148,7 +148,7 @@ namespace Coffee.UIExtensions
// Collect UIParticle if needed (same size as m_ParticleSystems)
CollectUIParticlesIfNeeded();
for (var particleIndex = 0; particleIndex < m_ParticleSystems.Count; particleIndex++)
for (var particleIndex = 0; particleIndex < this.m_ParticleSystems.Count; particleIndex++)
{
var particleSystem = m_ParticleSystems[particleIndex];
@@ -163,21 +163,21 @@ namespace Coffee.UIExtensions
particleSystem.GetParticles(particles, count);
var uiParticle = _uiParticles[particleIndex];
var dstPos = GetDestinationPosition(uiParticle, particleSystem);
var dstPos = this.GetDestinationPosition(uiParticle, particleSystem);
for (var i = 0; i < count; i++)
{
// Attracted
var p = particles[i];
if (0f < p.remainingLifetime && Vector3.Distance(p.position, dstPos) < m_DestinationRadius)
if (0f < p.remainingLifetime && Vector3.Distance(p.position, dstPos) < this.m_DestinationRadius)
{
p.remainingLifetime = 0f;
particles[i] = p;
if (m_OnAttracted != null)
if (this.m_OnAttracted != null)
{
try
{
m_OnAttracted.Invoke();
this.m_OnAttracted.Invoke();
}
catch (Exception e)
{
@@ -189,7 +189,7 @@ namespace Coffee.UIExtensions
}
// Calc attracting time
var delayTime = p.startLifetime * m_DelayRate;
var delayTime = p.startLifetime * this.m_DelayRate;
var duration = p.startLifetime - delayTime;
var time = Mathf.Max(0, p.startLifetime - p.remainingLifetime - delayTime);
@@ -197,7 +197,7 @@ namespace Coffee.UIExtensions
if (time <= 0) continue;
// Attract
p.position = GetAttractedPosition(p.position, dstPos, duration, time);
p.position = this.GetAttractedPosition(p.position, dstPos, duration, time);
p.velocity *= 0.5f;
particles[i] = p;
}

View File

@@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 5f0675613942149309588d556e33d990, type: 3}
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -17,18 +17,6 @@ namespace Coffee.UIExtensions
set => instance.m_EnableLinearToGamma = value;
}
[Header("Editor")]
[Tooltip("Hide the automatically generated objects.\n" +
" - UIParticleRenderer\n" +
" - UIParticle BakingCamera")]
[SerializeField]
private bool m_HideGeneratedObjects = true;
public static HideFlags globalHideFlags => instance.m_HideGeneratedObjects
? HideFlags.DontSave | HideFlags.NotEditable | HideFlags.HideInHierarchy | HideFlags.HideInInspector
: HideFlags.DontSave | HideFlags.NotEditable;
#if UNITY_EDITOR
[SettingsProvider]
private static SettingsProvider CreateSettingsProvider()

View File

@@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 5f0675613942149309588d556e33d990, type: 3}
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -4,6 +4,7 @@
#elif UNITY_2022_3_OR_NEWER
#define PS_BAKE_API_V2
#endif
using System;
using System.Collections.Generic;
using Coffee.UIParticleInternal;
@@ -24,7 +25,6 @@ namespace Coffee.UIExtensions
private static readonly CombineInstance[] s_CombineInstances = { new CombineInstance() };
private static readonly List<Material> s_Materials = new List<Material>(2);
private static MaterialPropertyBlock s_Mpb;
private static readonly List<Color32> s_Colors = new List<Color32>();
private static readonly Vector3[] s_Corners = new Vector3[4];
private bool _delay;
private int _index;
@@ -137,7 +137,6 @@ namespace Coffee.UIExtensions
{
base.OnEnable();
hideFlags = UIParticleProjectSettings.globalHideFlags;
if (!s_CombineInstances[0].mesh)
{
s_CombineInstances[0].mesh = new Mesh
@@ -162,7 +161,7 @@ namespace Coffee.UIExtensions
// Create renderer object.
var go = new GameObject("[generated] UIParticleRenderer", typeof(UIParticleRenderer))
{
hideFlags = UIParticleProjectSettings.globalHideFlags,
hideFlags = HideFlags.HideAndDontSave,
layer = parent.gameObject.layer
};
@@ -189,7 +188,6 @@ namespace Coffee.UIExtensions
if (!IsActive() || !_parent)
{
MaterialRepository.Release(ref _modifiedMaterial);
_modifiedMaterial = null;
return baseMaterial;
}
@@ -203,6 +201,7 @@ namespace Coffee.UIExtensions
return modifiedMaterial;
}
//
var hash = new Hash128(
modifiedMaterial ? (uint)modifiedMaterial.GetInstanceID() : 0,
texture ? (uint)texture.GetInstanceID() : 0,
@@ -215,10 +214,11 @@ namespace Coffee.UIExtensions
);
if (!MaterialRepository.Valid(hash, _modifiedMaterial))
{
MaterialRepository.Get(hash, ref _modifiedMaterial, () => new Material(modifiedMaterial)
MaterialRepository.Get(hash, ref _modifiedMaterial, x => new Material(x.mat)
{
hideFlags = HideFlags.HideAndDontSave
});
hideFlags = HideFlags.HideAndDontSave,
mainTexture = x.texture ? x.texture : x.mat.mainTexture
}, (mat: modifiedMaterial, texture));
}
return _modifiedMaterial;
@@ -424,12 +424,13 @@ namespace Coffee.UIExtensions
var components = ListPool<Component>.Rent();
GetComponents(typeof(IMeshModifier), components);
#pragma warning disable CS0618 // Type or member is obsolete
for (var i = 0; i < components.Count; i++)
{
#pragma warning disable CS0618 // Type or member is obsolete
((IMeshModifier)components[i]).ModifyMesh(workerMesh);
#pragma warning restore CS0618 // Type or member is obsolete
}
#pragma warning restore CS0618 // Type or member is obsolete
ListPool<Component>.Return(ref components);
}

View File

@@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 5f0675613942149309588d556e33d990, type: 3}
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -40,10 +40,7 @@
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Fog
{
Mode Off
}
Fog { Mode Off }
Blend One One
ColorMask [_ColorMask]
@@ -64,21 +61,21 @@
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
@@ -117,4 +114,4 @@
ENDCG
}
}
}
}

View File

@@ -2,7 +2,7 @@
"name": "com.coffee.ui-particle",
"displayName": "UI Particle",
"description": "This package provides a component to render particle effects for uGUI.\nThe particle rendering is maskable and sortable, without the need for an extra Camera, RenderTexture, or Canvas.",
"version": "4.10.0",
"version": "4.9.0",
"unity": "2018.2",
"license": "MIT",
"repository": {

View File

@@ -124,7 +124,7 @@ PlayerSettings:
bundleVersion: 1.0
preloadedAssets:
- {fileID: 11400000, guid: 86087a0847f384b538391745dad4565c, type: 2}
- {fileID: 11400000, guid: 4b9df7b8a4193489299b8f477348ae0c, type: 2}
- {fileID: 11400000, guid: e8e7744b163af4869b07b8f192c810ed, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1