TylerTemp / SaintsField

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

[GetComponentInPanret] doesn't work when in prefab edit (2020.3.48) #43

Closed laurentopia closed 1 month ago

laurentopia commented 2 months ago

[GetComponent] works fine, tho image image image

TylerTemp commented 2 months ago

Hi,

Can you check if you mean GetComponentInParents than GetComponentInParent?

For what I tested:

public class Issue43 : MonoBehaviour
{
    [GetComponentInParent] public MCUnit mcUnit;
}

Ensure I'm in prefab editing mode:

image

Attach MCUnit to PR_lankyman

image

Then attach Issue43 to it's directly children:

image

Both lankyman (a normal GameObject) and lankyman (1) (a prefab) works as expected

image

So maybe your MCUnit is not direct parent of your GetComponentInParent, thus you need GetComponentInParents

If not, please tell me where your GetComponentInParent attached in your screenshot so I can try re-produce this issue.

laurentopia commented 1 month ago

I think it was problem with HotReload breaking things again. It works as expected now, but sometimes not due to HR intercepting stuff.