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

Work at editor time? #5

Open
Petethegoat opened this issue Jun 15, 2023 · 4 comments
Open

Work at editor time? #5

Petethegoat opened this issue Jun 15, 2023 · 4 comments

Comments

@Petethegoat
Copy link

I find myself wanting injection to happen to some extent during edit mode, for setting things up correctly in OnValidate(), or just for use in editor scripts.

[Inject] public BoxCollider Box { get; }

void OnValidate()
{
	Box.isTrigger = true;
}

I do understand why this doesn't currently work, and I can't think of any super elegant solution off the top of my head.
I thought I'd mention it as something that'd be desirable on the off-chance there's a great way to support this that doesn't create loads of edge cases.

@Petethegoat
Copy link
Author

Possibly something that makes regular injection behave lazily at editor time?
Would have to be optional and enabled by the user somehow.

@bulleador
Copy link
Contributor

In terms of MonoBehaviour dependencies, that would make SerializeField completely obsolete in my projects. An additional LazyInEditor property would be great.

@apkd
Copy link
Owner

apkd commented Aug 20, 2023

Hey there, thanks for getting in touch. This would be a great feature to add. There's several ways it could be implemented. I think the most likely route would be to have the code compile slightly differently depending on whether the game is compiling in editor or making a build. This would let us keep optimal performance in player builds, by eliminating unnecessary Application.isPlaying checks. I'd rather avoid adding new attributes because I kinda think we already have too many 😅

I'd love to add this feature but I'm loaded with work at the moment, so I can't give you an ETA. Obviously, pull requests are welcome.

@Petethegoat
Copy link
Author

I think the most likely route would be to have the code compile slightly differently depending on whether the game is compiling in editor or making a build. This would let us keep optimal performance in player builds, by eliminating unnecessary Application.isPlaying checks. I'd rather avoid adding new attributes because I kinda think we already have too many 😅

This does sound good, my only fear is encountering different behaviour in editor vs in builds, could be hard to debug if someone isn't aware of this feature.

I might investigate it myself at some point, but the main project is demanding most of my attention at the moment.
Let me know if some indie sized sponsorship would help! Really appreciate your work.

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

No branches or pull requests

3 participants