SaintsField icon indicating copy to clipboard operation
SaintsField copied to clipboard

behavior of this? [GetComponent, HideInInspector]

Open laurentopia opened this issue 1 year ago • 2 comments

I think GetComponent only activates when the field is drawn by the inspector. Is there a way around that so i can both hide the variable and benefit from auto get?

laurentopia avatar Aug 19 '24 03:08 laurentopia

Not yet.

This situation will be better when I finish #70 . At this moment it's not possible

TylerTemp avatar Aug 20 '24 03:08 TylerTemp

Got it, no problem I'll set things by hand. Your attribs are already tons of work saved.

laurentopia avatar Aug 22 '24 00:08 laurentopia

Hi,

First of all, HideInInspector, uses some hack that changes the flow of AttributeDrawer. So HideInInspector will not be supported.

In 3.4.0, if you're on UI Toolkit, it's possible to just use HideIf. But for IMGUI, the changes are too much, so at this point I'd suggest use a bit hack

// sign, then hide
[GetComponent, HideIf(nameof(i75Hide))] public Issue75 i75Hide;
// just disable so no catch here
[GetComponent, DisableIf] public Issue75 i75Disable;

[Button]
private void PrintDebug()
{
    Debug.Log($"i75Hide={i75Hide}");
    Debug.Log($"i75Disable={i75Disable}");
}

The first one, will get rendered at first. And once the value is filled, the field will be hidden.

The second one, as it read, just disable it

And you can see the log that both field is signed.

image

image

TylerTemp avatar Oct 14 '24 14:10 TylerTemp