diff --git a/CHANGELOG.md b/CHANGELOG.md index 75c95a6..1001282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# [4.0.0-preview.8](https://github.com/mob-sakai/UIEffect/compare/v4.0.0-preview.7...v4.0.0-preview.8) (2020-06-04) + + +### change + +* change namespace ([7f4190c](https://github.com/mob-sakai/UIEffect/commit/7f4190c8c6f294e90869767a96194ec5ac4ba57f)) + + +### Features + +* modify EffectPlayer at runtime ([8483ba6](https://github.com/mob-sakai/UIEffect/commit/8483ba63cb546ca032915c166c0333fa5fd7aa76)), closes [#214](https://github.com/mob-sakai/UIEffect/issues/214) [#215](https://github.com/mob-sakai/UIEffect/issues/215) + + +### BREAKING CHANGES + +* If your code contained the UIEffect API, it would fail to compile. Please change the namespace from `Coffee.UIExtensions` to `Coffee.UIEffects`. + # [4.0.0-preview.7](https://github.com/mob-sakai/UIEffect/compare/v4.0.0-preview.6...v4.0.0-preview.7) (2020-05-11) diff --git a/README.md b/README.md index 1903111..a42cff1 100644 --- a/README.md +++ b/README.md @@ -113,18 +113,13 @@ Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) to insta



## How to play demo -#### For Unity 2019.1 or later +- For Unity 2019.1 or later + - Open `Package Manager` window and select `UI Effect` package in package list and click `Demo > Import in project` button +- For Unity 2018.4 or earlier + - Click `Assets/Samples/UIEffect/Import Demo` from menu -1. Open `Package Manager` window and select `UI Particle` package in package list -2. Click `Import in project` button -![](https://user-images.githubusercontent.com/12690315/79000480-a8bd4880-7b87-11ea-89c7-a17033a486ba.png) -3. The demo will be imported into `Assets/Samples/UI Effect/{version}/Demo`; open `UIEffect_Demo` scene and play it - -#### For Unity 2018.4 or earlier - -1. Select `Assets/Samples/UI Effect Demo` from menu -![Assets_と_Menubar](https://user-images.githubusercontent.com/12690315/79001101-dd7dcf80-7b88-11ea-9cf2-b44c6c5c9b17.png) -2. The demo will be imported into `Assets/Samples/UI Effect/{version}/Demo`; open `UIEffect_Demo` scene and play it +The assets will be imported into `Assets/Samples/UI Effect/{version}/Demo`. +Open ` diff --git a/Samples~/Demo/UIEffect_Demo.cs b/Samples~/Demo/UIEffect_Demo.cs index c769c67..5125eda 100644 --- a/Samples~/Demo/UIEffect_Demo.cs +++ b/Samples~/Demo/UIEffect_Demo.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { public class UIEffect_Demo : MonoBehaviour { diff --git a/Scripts/Common/BaseMaterialEffect.cs b/Scripts/Common/BaseMaterialEffect.cs index 83ba725..1669e09 100644 --- a/Scripts/Common/BaseMaterialEffect.cs +++ b/Scripts/Common/BaseMaterialEffect.cs @@ -6,7 +6,7 @@ using System.Text; using UnityEngine; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Abstract effect base for UI. @@ -43,7 +43,6 @@ namespace Coffee.UIExtensions foreach (var effect in syncEffects) { effect.SetMaterialDirty(); - // BaseConnector.FindConnector(effect.graphic).SetMaterialDirty(effect.graphic); } } diff --git a/Scripts/Common/BaseMeshEffect.cs b/Scripts/Common/BaseMeshEffect.cs index 7cc9a72..40d4e66 100644 --- a/Scripts/Common/BaseMeshEffect.cs +++ b/Scripts/Common/BaseMeshEffect.cs @@ -3,7 +3,7 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Base class for effects that modify the generated Mesh. @@ -16,14 +16,14 @@ namespace Coffee.UIExtensions { RectTransform _rectTransform; Graphic _graphic; - BaseConnector _connector; + GraphicConnector _connector; /// /// The Graphic attached to this GameObject. /// - protected BaseConnector connector + protected GraphicConnector connector { - get { return _connector ?? (_connector = BaseConnector.FindConnector(graphic)); } + get { return _connector ?? (_connector = GraphicConnector.FindConnector(graphic)); } } /// @@ -44,15 +44,6 @@ namespace Coffee.UIExtensions internal readonly List syncEffects = new List(0); - /// - /// The material for rendering. - /// - // public virtual Material material - // { - // get { return connector.GetMaterial(graphic); } - // set { connector.SetMaterial(graphic, value); } - // } - /// /// Call used to modify mesh. (legacy) /// @@ -146,7 +137,7 @@ namespace Coffee.UIExtensions // _initialized = true; // _graphic = _graphic ? _graphic : GetComponent(); // -// _connector = BaseConnector.FindConnector(_graphic); +// _connector = GraphicConnector.FindConnector(_graphic); // // // _canvasRenderer = _canvasRenderer ?? GetComponent (); // _rectTransform = _rectTransform ? _rectTransform : GetComponent(); diff --git a/Scripts/Common/EffectPlayer.cs b/Scripts/Common/EffectPlayer.cs index ad2376f..f60165a 100644 --- a/Scripts/Common/EffectPlayer.cs +++ b/Scripts/Common/EffectPlayer.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Effect player. diff --git a/Scripts/Connectors/BaseConnector.cs b/Scripts/Common/GraphicConnector.cs similarity index 71% rename from Scripts/Connectors/BaseConnector.cs rename to Scripts/Common/GraphicConnector.cs index 9fbb2d7..aa6f413 100644 --- a/Scripts/Connectors/BaseConnector.cs +++ b/Scripts/Common/GraphicConnector.cs @@ -1,17 +1,18 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; +using UnityEngine; using UnityEngine.UI; +using System; +using System.Collections.Generic; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { - public class BaseConnector + public class GraphicConnector { - private static readonly List s_Connectors = new List(); - private static readonly Dictionary s_ConnectorMap = new Dictionary(); - private static readonly BaseConnector s_EmptyConnector = new BaseConnector(); + private static readonly List s_Connectors = new List(); + + private static readonly Dictionary s_ConnectorMap = + new Dictionary(); + + private static readonly GraphicConnector s_EmptyConnector = new GraphicConnector(); #if UNITY_EDITOR [UnityEditor.InitializeOnLoadMethod] @@ -19,21 +20,21 @@ namespace Coffee.UIExtensions [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void Init() { - AddConnector(s_EmptyConnector); + AddConnector(new GraphicConnector()); } - protected static void AddConnector(BaseConnector connector) + protected static void AddConnector(GraphicConnector connector) { s_Connectors.Add(connector); s_Connectors.Sort((x, y) => y.priority - x.priority); } - public static BaseConnector FindConnector(Graphic graphic) + public static GraphicConnector FindConnector(Graphic graphic) { if (!graphic) return s_EmptyConnector; var type = graphic.GetType(); - BaseConnector connector = null; + GraphicConnector connector = null; if (s_ConnectorMap.TryGetValue(type, out connector)) return connector; foreach (var c in s_Connectors) @@ -47,6 +48,22 @@ namespace Coffee.UIExtensions return s_EmptyConnector; } + /// + /// Connector priority. + /// + protected virtual int priority + { + get { return -1; } + } + + /// + /// Extra channel. + /// + public virtual AdditionalCanvasShaderChannels extraChannel + { + get { return AdditionalCanvasShaderChannels.TexCoord1; } + } + /// /// The connector is valid for the component. /// @@ -60,52 +77,7 @@ namespace Coffee.UIExtensions /// public virtual Shader FindShader(string shaderName) { - return null; - } - - /// - /// Priority. - /// - protected virtual int priority - { - get { return -1; } - } - - /// - /// Extra channel. - /// - public virtual AdditionalCanvasShaderChannels extraChannel - { - get { return AdditionalCanvasShaderChannels.None; } - } - - /// - /// Set material. - /// - public virtual void SetMaterial(Graphic graphic, Material material) - { - } - - /// - /// Get material. - /// - public virtual Material GetMaterial(Graphic graphic) - { - return null; - } - - /// - /// Mark the vertices as dirty. - /// - public virtual void SetVerticesDirty(Graphic graphic) - { - } - - /// - /// Mark the material as dirty. - /// - public virtual void SetMaterialDirty(Graphic graphic) - { + return Shader.Find("Hidden/" + shaderName); } /// @@ -122,6 +94,24 @@ namespace Coffee.UIExtensions { } + /// + /// Mark the vertices as dirty. + /// + public virtual void SetVerticesDirty(Graphic graphic) + { + if (graphic) + graphic.SetVerticesDirty(); + } + + /// + /// Mark the material as dirty. + /// + public virtual void SetMaterialDirty(Graphic graphic) + { + if (graphic) + graphic.SetMaterialDirty(); + } + /// /// Event that is called just before Canvas rendering happens. /// This allows you to delay processing / updating of canvas based elements until just before they are rendered. @@ -133,7 +123,7 @@ namespace Coffee.UIExtensions /// /// Gets position factor for area. /// - public void GetPositionFactor(EffectArea area, int index, Rect rect, Vector2 position, out float x, out float y) + public virtual void GetPositionFactor(EffectArea area, int index, Rect rect, Vector2 position, out float x, out float y) { if (area == EffectArea.Fit) { @@ -147,22 +137,23 @@ namespace Coffee.UIExtensions } } - /// - /// Normalize vertex position by local matrix. - /// - public void GetNormalizedFactor(EffectArea area, int index, Matrix2x3 matrix, Vector2 position, - out Vector2 normalizedPos) - { - normalizedPos = matrix * position; - } - public virtual bool IsText(Graphic graphic) { - return false; + return graphic && graphic is Text; } public virtual void SetExtraChannel(ref UIVertex vertex, Vector2 value) { + vertex.uv1 = value; + } + + /// + /// Normalize vertex position by local matrix. + /// + public virtual void GetNormalizedFactor(EffectArea area, int index, Matrix2x3 matrix, Vector2 position, + out Vector2 normalizedPos) + { + normalizedPos = matrix * position; } } } diff --git a/Scripts/Connectors/GraphicConnector.cs.meta b/Scripts/Common/GraphicConnector.cs.meta similarity index 100% rename from Scripts/Connectors/GraphicConnector.cs.meta rename to Scripts/Common/GraphicConnector.cs.meta diff --git a/Scripts/Common/MaterialCache.cs b/Scripts/Common/MaterialCache.cs index 1279972..8d8ed93 100644 --- a/Scripts/Common/MaterialCache.cs +++ b/Scripts/Common/MaterialCache.cs @@ -5,7 +5,7 @@ using UnityEngine; using System.Text; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { public class MaterialCache { @@ -40,7 +40,8 @@ namespace Coffee.UIExtensions } #endif - public static Material Register(Material baseMaterial, Hash128 hash, System.Action onModifyMaterial, Graphic graphic) + public static Material Register(Material baseMaterial, Hash128 hash, + System.Action onModifyMaterial, Graphic graphic) { if (!hash.isValid) return null; diff --git a/Scripts/Common/Matrix2x3.cs b/Scripts/Common/Matrix2x3.cs index 5716d50..ec2cb69 100644 --- a/Scripts/Common/Matrix2x3.cs +++ b/Scripts/Common/Matrix2x3.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Matrix2x3. diff --git a/Scripts/Common/ParameterTexture.cs b/Scripts/Common/ParameterTexture.cs index cb890f4..3249828 100644 --- a/Scripts/Common/ParameterTexture.cs +++ b/Scripts/Common/ParameterTexture.cs @@ -4,7 +4,7 @@ using UnityEngine; using UnityEngine.Rendering; using System; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { public interface IParameterTexture { @@ -24,7 +24,7 @@ namespace Coffee.UIExtensions //################################ /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Channels. /// Instance limit. diff --git a/Scripts/Connectors.meta b/Scripts/Connectors.meta deleted file mode 100644 index 5ec68a0..0000000 --- a/Scripts/Connectors.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 73be53ea7d09c45bc83e7b957a5b99b5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Connectors/BaseConnector.cs.meta b/Scripts/Connectors/BaseConnector.cs.meta deleted file mode 100644 index 892259f..0000000 --- a/Scripts/Connectors/BaseConnector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1fa123391c81f40ffbbe761447b7913c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Connectors/GraphicConnector.cs b/Scripts/Connectors/GraphicConnector.cs deleted file mode 100644 index ba47501..0000000 --- a/Scripts/Connectors/GraphicConnector.cs +++ /dev/null @@ -1,70 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; - -namespace Coffee.UIExtensions -{ - public class GraphicConnector : BaseConnector - { -#if UNITY_EDITOR - [UnityEditor.InitializeOnLoadMethod] -#endif - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] - private static void Init() - { - AddConnector(new GraphicConnector()); - } - - protected override int priority - { - get { return 0; } - } - - public override Material GetMaterial(Graphic graphic) - { - return graphic ? graphic.material : null; - } - - public override void SetMaterial(Graphic graphic, Material material) - { - if (graphic) - graphic.material = material; - } - - public override AdditionalCanvasShaderChannels extraChannel - { - get { return AdditionalCanvasShaderChannels.TexCoord1; } - } - - public override Shader FindShader(string shaderName) - { - return Shader.Find("Hidden/" + shaderName); - } - - protected override bool IsValid(Graphic graphic) - { - return graphic; - } - - public override void SetVerticesDirty(Graphic graphic) - { - if (graphic) - graphic.SetVerticesDirty(); - } - - public override void SetMaterialDirty(Graphic graphic) - { - if (graphic) - graphic.SetMaterialDirty(); - } - - public override bool IsText(Graphic graphic) - { - return graphic && graphic is Text; - } - - public override void SetExtraChannel(ref UIVertex vertex, Vector2 value) - { - vertex.uv1 = value; - } - } -} diff --git a/Scripts/Editor/ImportSampleMenu.cs b/Scripts/Editor/ImportSampleMenu.cs index ca4fea8..c53fc9b 100644 --- a/Scripts/Editor/ImportSampleMenu.cs +++ b/Scripts/Editor/ImportSampleMenu.cs @@ -4,14 +4,15 @@ using System.Linq; using System.Text.RegularExpressions; using UnityEditor; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { - public static class ImportSampleMenu_UIEffect + public static class ImportSampleMenu { - [MenuItem("Assets/Samples/Import UIEffect Sample")] - private static void ImportSample() + private const string jsonGuid = "546af75b6221c4768be79d67c9cea1fb"; + + [MenuItem("Assets/Samples/UIEffect/Import Demo")] + private static void ImportDemo() { - const string jsonGuid = "546af75b6221c4768be79d67c9cea1fb"; ImportSample(jsonGuid, "Demo"); } diff --git a/Scripts/Editor/MaterialDirtyScope.cs b/Scripts/Editor/MaterialDirtyScope.cs index 22b4d0a..435e66e 100644 --- a/Scripts/Editor/MaterialDirtyScope.cs +++ b/Scripts/Editor/MaterialDirtyScope.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// Changes in this scope cause the graphic's material to be dirty. diff --git a/Scripts/Editor/UIDissolveEditor.cs b/Scripts/Editor/UIDissolveEditor.cs index f2ac336..29c2782 100644 --- a/Scripts/Editor/UIDissolveEditor.cs +++ b/Scripts/Editor/UIDissolveEditor.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Collections.Generic; using UnityEngine.UI; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// UIEffect editor. diff --git a/Scripts/Editor/UIEffectEditor.cs b/Scripts/Editor/UIEffectEditor.cs index a4bd4b7..028ee73 100644 --- a/Scripts/Editor/UIEffectEditor.cs +++ b/Scripts/Editor/UIEffectEditor.cs @@ -4,7 +4,7 @@ using UnityEngine; using System.Linq; using System; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// UIEffect editor. diff --git a/Scripts/Editor/UIGradientEditor.cs b/Scripts/Editor/UIGradientEditor.cs index c0729f6..493c51d 100644 --- a/Scripts/Editor/UIGradientEditor.cs +++ b/Scripts/Editor/UIGradientEditor.cs @@ -2,7 +2,7 @@ using UnityEngine; using UnityEngine.UI; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// UIEffect editor. diff --git a/Scripts/Editor/UIHsvModifierEditor.cs b/Scripts/Editor/UIHsvModifierEditor.cs index 0f087ca..6d54a55 100644 --- a/Scripts/Editor/UIHsvModifierEditor.cs +++ b/Scripts/Editor/UIHsvModifierEditor.cs @@ -3,7 +3,7 @@ using UnityEditorInternal; using UnityEngine; using System.Linq; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// UIEffect editor. @@ -50,4 +50,4 @@ namespace Coffee.UIExtensions.Editors serializedObject.ApplyModifiedProperties(); } } -} \ No newline at end of file +} diff --git a/Scripts/Editor/UIShadowEditor.cs b/Scripts/Editor/UIShadowEditor.cs index a46fb83..64f01d6 100644 --- a/Scripts/Editor/UIShadowEditor.cs +++ b/Scripts/Editor/UIShadowEditor.cs @@ -2,7 +2,7 @@ using UnityEditorInternal; using UnityEngine; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// UIShadow editor. diff --git a/Scripts/Editor/UIShinyEditor.cs b/Scripts/Editor/UIShinyEditor.cs index 2937357..e77432a 100644 --- a/Scripts/Editor/UIShinyEditor.cs +++ b/Scripts/Editor/UIShinyEditor.cs @@ -3,7 +3,7 @@ using UnityEditorInternal; using UnityEngine; using System.Linq; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// UIEffect editor. @@ -99,4 +99,4 @@ namespace Coffee.UIExtensions.Editors serializedObject.ApplyModifiedProperties(); } } -} \ No newline at end of file +} diff --git a/Scripts/Editor/UITransitionEffectEditor.cs b/Scripts/Editor/UITransitionEffectEditor.cs index 22aa088..803c9bf 100644 --- a/Scripts/Editor/UITransitionEffectEditor.cs +++ b/Scripts/Editor/UITransitionEffectEditor.cs @@ -3,7 +3,7 @@ using UnityEditorInternal; using UnityEngine; using System.Linq; -namespace Coffee.UIExtensions.Editors +namespace Coffee.UIEffects.Editors { /// /// UIEffect editor. @@ -112,4 +112,4 @@ namespace Coffee.UIExtensions.Editors serializedObject.ApplyModifiedProperties(); } } -} \ No newline at end of file +} diff --git a/Scripts/Enums/BlurMode.cs b/Scripts/Enums/BlurMode.cs index 68c5604..e3ef417 100644 --- a/Scripts/Enums/BlurMode.cs +++ b/Scripts/Enums/BlurMode.cs @@ -1,4 +1,4 @@ -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Blur effect mode. diff --git a/Scripts/Enums/ColorMode.cs b/Scripts/Enums/ColorMode.cs index a94ef1e..567624b 100644 --- a/Scripts/Enums/ColorMode.cs +++ b/Scripts/Enums/ColorMode.cs @@ -1,4 +1,4 @@ -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Color effect mode. diff --git a/Scripts/Enums/EffectArea.cs b/Scripts/Enums/EffectArea.cs index 334e8b4..4e5fa28 100644 --- a/Scripts/Enums/EffectArea.cs +++ b/Scripts/Enums/EffectArea.cs @@ -1,7 +1,7 @@ using UnityEngine; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Area for effect. diff --git a/Scripts/Enums/EffectMode.cs b/Scripts/Enums/EffectMode.cs index 8c08578..84f3eb4 100644 --- a/Scripts/Enums/EffectMode.cs +++ b/Scripts/Enums/EffectMode.cs @@ -1,4 +1,4 @@ -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Effect mode. diff --git a/Scripts/Enums/ShadowStyle.cs b/Scripts/Enums/ShadowStyle.cs index d78b718..1cfe058 100644 --- a/Scripts/Enums/ShadowStyle.cs +++ b/Scripts/Enums/ShadowStyle.cs @@ -1,4 +1,4 @@ -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Shadow effect style. diff --git a/Scripts/UIDissolve.cs b/Scripts/UIDissolve.cs index 928c9c3..095174c 100644 --- a/Scripts/UIDissolve.cs +++ b/Scripts/UIDissolve.cs @@ -7,7 +7,7 @@ using System.Text; using System.Linq; using System.IO; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Dissolve effect for uGUI. @@ -196,6 +196,11 @@ namespace Coffee.UIExtensions get { return s_ParamTex; } } + EffectPlayer effectPlayer + { + get { return m_Player ?? (m_Player = new EffectPlayer()); } + } + public override Hash128 GetMaterialHash(Material material) { if (!isActiveAndEnabled || !material || !material.shader) @@ -213,7 +218,7 @@ namespace Coffee.UIExtensions public override void ModifyMaterial(Material newMaterial, Graphic graphic) { - var connector = BaseConnector.FindConnector(graphic); + var connector = GraphicConnector.FindConnector(graphic); newMaterial.shader = connector.FindShader("UIDissolve"); SetShaderVariants(newMaterial, m_ColorMode); @@ -288,7 +293,7 @@ namespace Coffee.UIExtensions /// public void Play(bool reset = true) { - _player.Play(reset); + effectPlayer.Play(reset); } /// @@ -296,24 +301,19 @@ namespace Coffee.UIExtensions /// public void Stop(bool reset = true) { - _player.Stop(reset); + effectPlayer.Stop(reset); } protected override void OnEnable() { base.OnEnable(); - _player.OnEnable((f) => effectFactor = m_Reverse ? 1f - f : f); + effectPlayer.OnEnable((f) => effectFactor = m_Reverse ? 1f - f : f); } protected override void OnDisable() { base.OnDisable(); - _player.OnDisable(); - } - - EffectPlayer _player - { - get { return m_Player ?? (m_Player = new EffectPlayer()); } + effectPlayer.OnDisable(); } } } diff --git a/Scripts/UIEffect.cs b/Scripts/UIEffect.cs index 69f2752..42ac0ce 100644 --- a/Scripts/UIEffect.cs +++ b/Scripts/UIEffect.cs @@ -10,7 +10,7 @@ using UnityEditor; #endif -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// UIEffect. @@ -192,7 +192,7 @@ namespace Coffee.UIExtensions public override void ModifyMaterial(Material newMaterial, Graphic graphic) { - var connector = BaseConnector.FindConnector(graphic); + var connector = GraphicConnector.FindConnector(graphic); newMaterial.shader = connector.FindShader("UIEffect"); SetShaderVariants(newMaterial, m_EffectMode, m_ColorMode, m_BlurMode, diff --git a/Scripts/UIFlip.cs b/Scripts/UIFlip.cs index 784f57b..2cb7055 100644 --- a/Scripts/UIFlip.cs +++ b/Scripts/UIFlip.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { [DisallowMultipleComponent] [AddComponentMenu("UI/UIEffects/UIFlip", 102)] @@ -16,7 +16,7 @@ namespace Coffee.UIExtensions private bool m_Veritical = false; /// - /// Gets or sets a value indicating whether this should be flipped horizontally. + /// Gets or sets a value indicating whether this should be flipped horizontally. /// /// true if be flipped horizontally; otherwise, false. public bool horizontal @@ -31,7 +31,7 @@ namespace Coffee.UIExtensions } /// - /// Gets or sets a value indicating whether this should be flipped vertically. + /// Gets or sets a value indicating whether this should be flipped vertically. /// /// true if be flipped horizontally; otherwise, false. public bool vertical diff --git a/Scripts/UIGradient.cs b/Scripts/UIGradient.cs index 8a22c54..b184182 100755 --- a/Scripts/UIGradient.cs +++ b/Scripts/UIGradient.cs @@ -1,7 +1,7 @@ using UnityEngine; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// UIGradient. diff --git a/Scripts/UIHsvModifier.cs b/Scripts/UIHsvModifier.cs index f69b7b6..16335e7 100644 --- a/Scripts/UIHsvModifier.cs +++ b/Scripts/UIHsvModifier.cs @@ -4,7 +4,7 @@ using UnityEngine.Serialization; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// HSV Modifier. @@ -127,7 +127,7 @@ namespace Coffee.UIExtensions public override void ModifyMaterial(Material newMaterial, Graphic graphic) { - var connector = BaseConnector.FindConnector(graphic); + var connector = GraphicConnector.FindConnector(graphic); newMaterial.shader = connector.FindShader("UIHsvModifier"); paramTex.RegisterMaterial(newMaterial); diff --git a/Scripts/UIShadow.cs b/Scripts/UIShadow.cs index 336794c..42ec596 100644 --- a/Scripts/UIShadow.cs +++ b/Scripts/UIShadow.cs @@ -10,7 +10,7 @@ using UnityEditor; #endif -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// UIEffect. diff --git a/Scripts/UIShiny.cs b/Scripts/UIShiny.cs index bb64be9..b2cabee 100644 --- a/Scripts/UIShiny.cs +++ b/Scripts/UIShiny.cs @@ -5,7 +5,7 @@ using UnityEngine.Serialization; using UnityEngine.UI; using System.Collections; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// UIEffect. @@ -153,13 +153,18 @@ namespace Coffee.UIExtensions get { return s_ParamTex; } } + EffectPlayer effectPlayer + { + get { return m_Player ?? (m_Player = new EffectPlayer()); } + } + /// /// This function is called when the object becomes enabled and active. /// protected override void OnEnable() { base.OnEnable(); - _player.OnEnable(f => effectFactor = f); + effectPlayer.OnEnable(f => effectFactor = f); } /// @@ -168,7 +173,7 @@ namespace Coffee.UIExtensions protected override void OnDisable() { base.OnDisable(); - _player.OnDisable(); + effectPlayer.OnDisable(); } @@ -187,7 +192,7 @@ namespace Coffee.UIExtensions public override void ModifyMaterial(Material newMaterial, Graphic graphic) { - var connector = BaseConnector.FindConnector(graphic); + var connector = GraphicConnector.FindConnector(graphic); newMaterial.shader = connector.FindShader("UIShiny"); paramTex.RegisterMaterial(newMaterial); @@ -233,7 +238,7 @@ namespace Coffee.UIExtensions /// public void Play(bool reset = true) { - _player.Play(reset); + effectPlayer.Play(reset); } /// @@ -241,7 +246,7 @@ namespace Coffee.UIExtensions /// public void Stop(bool reset = true) { - _player.Stop(reset); + effectPlayer.Stop(reset); } protected override void SetEffectParamsDirty() @@ -269,10 +274,5 @@ namespace Coffee.UIExtensions || _lastEffectArea != m_EffectArea) SetVerticesDirty(); } - - EffectPlayer _player - { - get { return m_Player ?? (m_Player = new EffectPlayer()); } - } } } diff --git a/Scripts/UISyncEffect.cs b/Scripts/UISyncEffect.cs index 3214076..ada9be8 100644 --- a/Scripts/UISyncEffect.cs +++ b/Scripts/UISyncEffect.cs @@ -4,7 +4,7 @@ using UnityEngine; using UnityEngine.UI; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Dissolve effect for uGUI. diff --git a/Scripts/UITransitionEffect.cs b/Scripts/UITransitionEffect.cs index 603f98a..3051249 100644 --- a/Scripts/UITransitionEffect.cs +++ b/Scripts/UITransitionEffect.cs @@ -3,7 +3,7 @@ using UnityEngine.UI; using UnityEngine.Serialization; using System; -namespace Coffee.UIExtensions +namespace Coffee.UIEffects { /// /// Transition effect. @@ -192,13 +192,18 @@ namespace Coffee.UIExtensions set { m_PassRayOnHidden = value; } } + EffectPlayer effectPlayer + { + get { return m_Player ?? (m_Player = new EffectPlayer()); } + } + /// /// Show transition. /// public void Show(bool reset = true) { - _player.loop = false; - _player.Play(reset, f => effectFactor = f); + effectPlayer.loop = false; + effectPlayer.Play(reset, f => effectFactor = f); } /// @@ -206,8 +211,8 @@ namespace Coffee.UIExtensions /// public void Hide(bool reset = true) { - _player.loop = false; - _player.Play(reset, f => effectFactor = 1 - f); + effectPlayer.loop = false; + effectPlayer.Play(reset, f => effectFactor = 1 - f); } @@ -228,7 +233,7 @@ namespace Coffee.UIExtensions public override void ModifyMaterial(Material newMaterial, Graphic graphic) { - var connector = BaseConnector.FindConnector(graphic); + var connector = GraphicConnector.FindConnector(graphic); newMaterial.shader = connector.FindShader("UITransition"); SetShaderVariants(newMaterial, m_EffectMode); @@ -277,8 +282,8 @@ namespace Coffee.UIExtensions protected override void OnEnable() { base.OnEnable(); - _player.OnEnable(null); - _player.loop = false; + effectPlayer.OnEnable(null); + effectPlayer.loop = false; } /// @@ -287,7 +292,7 @@ namespace Coffee.UIExtensions protected override void OnDisable() { base.OnDisable(); - _player.OnDisable(); + effectPlayer.OnDisable(); } protected override void SetEffectParamsDirty() @@ -323,10 +328,5 @@ namespace Coffee.UIExtensions if (_lastKeepAspectRatio != m_KeepAspectRatio) SetVerticesDirty(); } - - EffectPlayer _player - { - get { return m_Player ?? (m_Player = new EffectPlayer()); } - } } } diff --git a/package.json b/package.json index 0bd5d93..ec8e9ba 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "com.coffee.ui-effect", - "displayName": "UIEffect", - "description": "UIEffect provides visual effect components for Unity UI.\nLet's decorate your UI with effects!", - "version": "4.0.0-preview.7", + "displayName": "UI Effect", + "description": "UI Effect provides visual effect components for Unity UI.\nLet's decorate your UI with effects!", + "version": "4.0.0-preview.8", "unity": "2017.1", "license": "MIT", "repository": {