rokojori_action_library/Runtime/Procedural/Textures/TextureStack/TextureStackNotify.cs

49 lines
1.9 KiB
C#

using Godot;
using System;
using Rokojori.Extensions;
namespace Rokojori
{
/** One switch for every `changed` signal the TextureStack data resources
emit.
<marked>Off by default, and that is the point.</marked> Session 4 gave all
~55 exported values on TextureStack, TextureStackLayer, its subclasses,
TextureStackMask, TextureStackStamps and TextureSettings a setter that
calls EmitChanged(), following Godot's own convention for custom
resources. Sessions 5 and 6 then spent a long time establishing that the
recompositing driven off those signals was never reliable, and session 7
found the signals themselves are what the editor reacts badly to: with
the stack reached through the composited texture, editing a layer
interrupts the inspector - even through a hand-drawn UI with no property
editors involved at all, which is the case that rules out everything
else.
So the signals stay in the code but stop firing. Compositing is driven
explicitly instead - on load, from a button, or from whatever is ticking
the stack - which is the direction the architecture is moving anyway.
Turn it back on to A/B the behaviour, or if a consumer genuinely needs
Resource.Changed from this data. Note that
TextureStackTexture2D's auto-on-change hooks subscribe to exactly these
signals, so with this off they go quiet and only compositeOnLoad, the
Composite button and CompositeTextureStack drive it.
*/
public static class TextureStackNotify
{
/** Whether the data resources emit Resource.Changed from their setters. */
public static bool emitChanged = true;
/** Called by every setter in place of EmitChanged(). */
public static void Changed( Resource resource )
{
if ( ! emitChanged || resource == null )
{
return;
}
resource.EmitChanged();
}
}
}