Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any option to have [GetComponent] not override user set reference? #72

Closed
laurentopia opened this issue Aug 11, 2024 · 15 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@laurentopia
Copy link

I'd like to use [GetComponent] to auto set a default value that can be overridden by the user.
But GetComponent overrides user value.
Is there a way around that?

@TylerTemp
Copy link
Owner

Hi,

this is now possible in 3.4.0:

[GetComponent(EXP.Silent | EXP.NoPicker)] public Dummy issue72Dummy;
[GetComponent(EXP.Silent | EXP.NoPicker | EXP.NoResignButton)] public Dummy issue72DummySimple;

image

The config is kinda tedious. It might be optimized on a later version.

Note: This update might contain bugs.

@TylerTemp TylerTemp added the enhancement New feature or request label Oct 14, 2024
@laurentopia
Copy link
Author

is it X or the cycling button? in the other post it was an X so maybe I don't understand its purpose

@TylerTemp
Copy link
Owner

Hi,

"X" means the value is manually signed, but the Get* attribute actually find nothing, so a "x" will allow you to remove the value.

"Reload" means the value is manually signed, but the Get* attibute find a value which is different from the current value, so a "Reload" will allow you to sign to a "correct" value, rather than the "current" value.

And EXP.NoResignButton will completely hide these buttons.

@laurentopia
Copy link
Author

this isn't working

equHKb88Qt.mp4

image

@TylerTemp
Copy link
Owner

Hi,

To use this feature, you need to at lease set EXP.Silent:

// simple
[GetComponentInChildren(EXP.Silent)] public MCMineable source;
// no picker button, no resign/remove button
[GetComponentInChildren(EXP.Silent | EXP.NoPicker | EXP.NoResignButton)] public MCMineable sourcePlain;
Unity_6P8yr3lWNK.mp4

I do plan to make a config function to set default config globally for many attributes. But that will be much later, after I finish some important features first.

@laurentopia
Copy link
Author

Ok. Why silent? Seems like a good default behavior.

@TylerTemp
Copy link
Owner

Well, I can not give a good reason.

When I design GetComponentByPath, which was originally designed to be the parent of all the auto-getter attributes, it behaves exactly like Silent. I'd like to think of it as a good design.

When I refactored it into GetByXPath, it took way too much time than I expected. When on its final touch, I actually lost track of which should be the default behavior.

When I'm working in the company, one thing I need to do constantly is: to re-bind all the lost references after a code merge. Yep, we decide not to merge the Unity scene because it's just not possible: Unity has a so-called yaml-merger, and it sucks. So whenever I merge the scenes, I just throw away my scenes and manually add everything back into the remote one. After manually adding the object & script, then is the magic part: because the auto-getter attributes will aggressively sign the value to the "found" value, all my setup will be correct, with no need to manually click the "re-sign button".

So, with not enough thought, I picked that aggressive behavior as the default. And I regret it...

Yep, that's the story. That's also why I plan to support a config file to allow to change of the default behavior globally (like what DOTween does).

@laurentopia
Copy link
Author

laurentopia commented Nov 4, 2024

oh boy, it's like thinking of a name for a method then you're stuck with a naming convention...

@TylerTemp
Copy link
Owner

Ok. Why silent? Seems like a good default behavior.

Hi,

Since 3.4.11 you can use Window/Saints/Create or Edit SaintsField Config to tweak the config of the default behavior of auto getters.

@laurentopia
Copy link
Author

Cool, I was just running into default collision!

@laurentopia
Copy link
Author

laurentopia commented Nov 13, 2024

just updated to 3.4.11 and I'm running into this new bug.
image
Maybe this accessor was added after 2020

@TylerTemp
Copy link
Owner

TylerTemp commented Nov 13, 2024

just updated to 3.4.11 and I'm running into this new bug. image Maybe this accessor was added after 2020

Hi,

Can you copy paste the error? Looks like some issue with reading the config file

Also can you check "Assets/Editor Default Resources/SaintsField/SaintsFieldConfig.asset", can it be correctly displayed?

@TylerTemp
Copy link
Owner

Oh holy fuck... your version is indeed a bit low that does not have ManagedReference yet

I'll fix it soon

@TylerTemp
Copy link
Owner

Sorry for the trouble, it's been fixed in 3.4.12

@laurentopia
Copy link
Author

No worry, I needed to go to bed anyway :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants