mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 09:52:38 +08:00
e32f620081
# [4.0.0-preview.2](https://github.com/mob-sakai/UIEffect/compare/v4.0.0-preview.1...v4.0.0-preview.2) (2020-04-10) ### Bug Fixes * compilation fails on build ([f34ae2c](https://github.com/mob-sakai/UIEffect/commit/f34ae2ce0f834eeb47927f2c0f8d6384adfe79da)) * fix project settings ([8685165](https://github.com/mob-sakai/UIEffect/commit/8685165f41ec0a97c6647689a5596a2d014d563a)), closes [#198](https://github.com/mob-sakai/UIEffect/issues/198) [#195](https://github.com/mob-sakai/UIEffect/issues/195) [#189](https://github.com/mob-sakai/UIEffect/issues/189) [#173](https://github.com/mob-sakai/UIEffect/issues/173) [#104](https://github.com/mob-sakai/UIEffect/issues/104) [#158](https://github.com/mob-sakai/UIEffect/issues/158) [#143](https://github.com/mob-sakai/UIEffect/issues/143)
84 lines
2.3 KiB
C#
84 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
namespace Coffee.UIExtensions
|
|
{
|
|
/// <summary>
|
|
/// Dissolve effect for uGUI.
|
|
/// </summary>
|
|
[ExecuteInEditMode]
|
|
public class UISyncEffect : BaseMaterialEffect
|
|
{
|
|
[Tooltip("The target effect to synchronize.")] [SerializeField]
|
|
private BaseMeshEffect m_TargetEffect;
|
|
|
|
public BaseMeshEffect targetEffect
|
|
{
|
|
get { return m_TargetEffect != this ? m_TargetEffect : null; }
|
|
set
|
|
{
|
|
if (m_TargetEffect == value) return;
|
|
m_TargetEffect = value;
|
|
|
|
SetVerticesDirty();
|
|
SetMaterialDirty();
|
|
SetEffectParamsDirty();
|
|
}
|
|
}
|
|
|
|
protected override void OnEnable()
|
|
{
|
|
if (targetEffect)
|
|
targetEffect.syncEffects.Add(this);
|
|
base.OnEnable();
|
|
}
|
|
|
|
protected override void OnDisable()
|
|
{
|
|
if (targetEffect)
|
|
targetEffect.syncEffects.Remove(this);
|
|
base.OnDisable();
|
|
}
|
|
|
|
public override Hash128 GetMaterialHash(Material baseMaterial)
|
|
{
|
|
if (!isActiveAndEnabled) return k_InvalidHash;
|
|
|
|
var matEffect = targetEffect as BaseMaterialEffect;
|
|
if (!matEffect || !matEffect.isActiveAndEnabled) return k_InvalidHash;
|
|
|
|
return matEffect.GetMaterialHash(baseMaterial);
|
|
}
|
|
|
|
public override void ModifyMaterial(Material newMaterial, Graphic graphic)
|
|
{
|
|
if (!isActiveAndEnabled) return;
|
|
|
|
var matEffect = targetEffect as BaseMaterialEffect;
|
|
if (!matEffect || !matEffect.isActiveAndEnabled) return;
|
|
|
|
matEffect.ModifyMaterial(newMaterial, graphic);
|
|
}
|
|
|
|
public override void ModifyMesh(VertexHelper vh, Graphic graphic)
|
|
{
|
|
if (!isActiveAndEnabled) return;
|
|
if (!targetEffect || !targetEffect.isActiveAndEnabled) return;
|
|
|
|
targetEffect.ModifyMesh(vh, graphic);
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
protected override void OnValidate()
|
|
{
|
|
SetVerticesDirty();
|
|
SetMaterialDirty();
|
|
SetEffectParamsDirty();
|
|
}
|
|
#endif
|
|
}
|
|
}
|