// #if UNITY_EDITOR // protected override void OnValidate() // { // effectDistance = m_EffectDistance; // base.OnValidate(); // } // #endif // #if TMP_PRESENT // protected void OnCullStateChanged (bool state) // { // SetVerticesDirty (); // } // // Vector2 res; // protected override void LateUpdate () // { // if (res.x != Screen.width || res.y != Screen.height) // { // res.x = Screen.width; // res.y = Screen.height; // SetVerticesDirty (); // } // if (textMeshPro && transform.hasChanged) // { // transform.hasChanged = false; // } // base.LateUpdate (); // } // #endif /// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh, Graphic graphic) { if (!isActiveAndEnabled || vh.currentVertCount <= 0 || m_Style == ShadowStyle.None) { return; } vh.GetUIVertexStream(s_Verts); GetComponents <UIShadow>(tmpShadows); foreach (var s in tmpShadows) { if (!s.isActiveAndEnabled) { continue; } if (s == this) { foreach (var s2 in tmpShadows) { s2._graphicVertexCount = s_Verts.Count; } } break; } tmpShadows.Clear(); //================================ // Append shadow vertices. //================================ { _uiEffect = _uiEffect ? _uiEffect : GetComponent <UIEffect>(); var start = s_Verts.Count - _graphicVertexCount; var end = s_Verts.Count; if (paramTex != null && _uiEffect && _uiEffect.isActiveAndEnabled) { paramTex.SetData(this, 0, _uiEffect.effectFactor); // param.x : effect factor paramTex.SetData(this, 1, 255); // param.y : color factor paramTex.SetData(this, 2, m_BlurFactor); // param.z : blur factor } ApplyShadow(s_Verts, effectColor, ref start, ref end, effectDistance, style, useGraphicAlpha); } vh.Clear(); vh.AddUIVertexTriangleStream(s_Verts); s_Verts.Clear(); }
protected override void OnDisable() { base.OnDisable(); _uiEffect = null; if (paramTex == null) { return; } paramTex.Unregister(this); paramTex = null; }
protected override void OnEnable() { base.OnEnable(); _uiEffect = GetComponent <UIEffect>(); if (!_uiEffect) { return; } paramTex = _uiEffect.paramTex; paramTex.Register(this); }