From d69611d66431e28ea35477c6781a00d57ae04fa3 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Apr 2021 21:13:03 +0800 Subject: =?UTF-8?q?*=E5=9B=A0=E4=B8=BA=E6=B2=A1=E6=9C=89meta=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4missing=EF=BC=8C=E5=88=A0=E9=99=A4UIEffect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIEffect/Program/Common/GraphicConnector.cs | 151 --------------------- 1 file changed, 151 deletions(-) delete mode 100644 Assets/Test/UIEffect/Program/Common/GraphicConnector.cs (limited to 'Assets/Test/UIEffect/Program/Common/GraphicConnector.cs') diff --git a/Assets/Test/UIEffect/Program/Common/GraphicConnector.cs b/Assets/Test/UIEffect/Program/Common/GraphicConnector.cs deleted file mode 100644 index 3046297..0000000 --- a/Assets/Test/UIEffect/Program/Common/GraphicConnector.cs +++ /dev/null @@ -1,151 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; -using System; -using System.Collections.Generic; - -namespace Coffee.UIEffects -{ - public class GraphicConnector - { - 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] -#endif - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] - private static void Init() - { - AddConnector(new GraphicConnector()); - } - - protected static void AddConnector(GraphicConnector connector) - { - s_Connectors.Add(connector); - s_Connectors.Sort((x, y) => y.priority - x.priority); - } - - public static GraphicConnector FindConnector(Graphic graphic) - { - if (!graphic) return s_EmptyConnector; - - var type = graphic.GetType(); - GraphicConnector connector = null; - if (s_ConnectorMap.TryGetValue(type, out connector)) return connector; - - foreach (var c in s_Connectors) - { - if (!c.IsValid(graphic)) continue; - - s_ConnectorMap.Add(type, c); - return c; - } - - 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. - /// - protected virtual bool IsValid(Graphic graphic) - { - return true; - } - - /// - /// Find effect shader. - /// - public virtual Shader FindShader(string shaderName) - { - return Shader.Find("Hidden/" + shaderName); - } - - /// - /// This function is called when the object becomes enabled and active. - /// - public virtual void OnEnable(Graphic graphic) - { - } - - /// - /// This function is called when the behaviour becomes disabled () or inactive. - /// - public virtual void OnDisable(Graphic graphic) - { - } - - /// - /// 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(); - } - - /// - /// Gets position factor for area. - /// - public virtual void GetPositionFactor(EffectArea area, int index, Rect rect, Vector2 position, out float x, out float y) - { - if (area == EffectArea.Fit) - { - x = Mathf.Clamp01((position.x - rect.xMin) / rect.width); - y = Mathf.Clamp01((position.y - rect.yMin) / rect.height); - } - else - { - x = Mathf.Clamp01(position.x / rect.width + 0.5f); - y = Mathf.Clamp01(position.y / rect.height + 0.5f); - } - } - - public virtual bool IsText(Graphic graphic) - { - 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; - } - } -} -- cgit v1.1-26-g67d0