TylerTemp / SaintsField

A Unity Inspector extension tool focusing on script fields inspector enhancement
MIT License
184 stars 10 forks source link

behavior of this? [GetComponent, HideInInspector] #75

Closed laurentopia closed 1 week ago

laurentopia commented 2 months ago

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?

TylerTemp commented 2 months ago

Not yet.

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

laurentopia commented 2 months ago

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

TylerTemp commented 3 weeks ago

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