fix #42; The masked images all disappear when game view is resized

pull/87/head
mob-sakai 2019-03-16 16:51:21 +09:00
parent 7a9efce141
commit a4353a6f9e
1 changed files with 11 additions and 0 deletions

View File

@ -155,6 +155,7 @@ namespace Coffee.UIExtensions
{ {
_softMaskBuffer = RenderTexture.GetTemporary(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default); _softMaskBuffer = RenderTexture.GetTemporary(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
hasChanged = true; hasChanged = true;
_hasStencilStateChanged = true;
} }
return _softMaskBuffer; return _softMaskBuffer;
@ -289,6 +290,7 @@ namespace Coffee.UIExtensions
graphic.SetVerticesDirty(); graphic.SetVerticesDirty();
base.OnEnable(); base.OnEnable();
_hasStencilStateChanged = false;
} }
/// <summary> /// <summary>
@ -324,6 +326,7 @@ namespace Coffee.UIExtensions
ReleaseRT(ref _softMaskBuffer); ReleaseRT(ref _softMaskBuffer);
base.OnDisable(); base.OnDisable();
_hasStencilStateChanged = false;
} }
/// <summary> /// <summary>
@ -360,6 +363,7 @@ namespace Coffee.UIExtensions
graphic.SetMaterialDirty(); graphic.SetMaterialDirty();
OnTransformParentChanged(); OnTransformParentChanged();
base.OnValidate(); base.OnValidate();
_hasStencilStateChanged = false;
} }
#endif #endif
@ -383,6 +387,8 @@ namespace Coffee.UIExtensions
SoftMask _parent; SoftMask _parent;
List<SoftMask> _children = new List<SoftMask>(); List<SoftMask> _children = new List<SoftMask>();
bool _hasChanged = false; bool _hasChanged = false;
bool _hasStencilStateChanged = false;
Material material { get { return _material ? _material : _material = new Material(s_SoftMaskShader ? s_SoftMaskShader : s_SoftMaskShader = Resources.Load<Shader>("SoftMask")){ hideFlags = HideFlags.HideAndDontSave }; } } Material material { get { return _material ? _material : _material = new Material(s_SoftMaskShader ? s_SoftMaskShader : s_SoftMaskShader = Resources.Load<Shader>("SoftMask")){ hideFlags = HideFlags.HideAndDontSave }; } }
@ -421,6 +427,11 @@ namespace Coffee.UIExtensions
if (!sm._parent) if (!sm._parent)
{ {
sm.UpdateMaskTexture(); sm.UpdateMaskTexture();
if (sm._hasStencilStateChanged)
{
sm._hasStencilStateChanged = false;
MaskUtilities.NotifyStencilStateChanged (sm);
}
} }
} }
} }