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

Enable library developers to access to the lib instance or inject argument objects to it during runtime #19

Open
wixette opened this issue Nov 4, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@wixette
Copy link
Owner

wixette commented Nov 4, 2021

So far custom libraries are instantiated only with Activator.CreateInstance(libClass); and the library creator has no straightforward way to access the library instance.

Given the current implementation, it's a bit hard for library developers to inject objects to the library instance in runtime (considering in a Unity game the GameManager instance needs to be passed in). Possible ways include using a singleton (global) as the proxy, etc. Instead, the following solutions could be way better and worth being considered:

  • Enable lib creators to instantiate the lib with passed-in arguments. Or,
  • Enable lib creators to inject argument objects to a lib instance during runtime. Or,
  • Let lib creators define a Context class type and associate an instance of the Context type with the lib instance. Or,
  • Let lib creators define their own logic (as a callback closure) to instantiate the lib. Or,
  • ...
@wixette wixette added the enhancement New feature or request label Nov 4, 2021
@wixette wixette self-assigned this Nov 4, 2021
@ratkingsminion
Copy link

Hallo, is this still in the works? Right now I'd be very interested in being able to access a library instance (just so I can inject the object that my Engine is "attached" to).

@wixette
Copy link
Owner Author

wixette commented Sep 3, 2022

Hallo, is this still in the works? Right now I'd be very interested in being able to access a library instance (just so I can inject the object that my Engine is "attached" to).

Ah, yes, it is still in the plan. My bandwidth has been occupied with other tasks. I will try to make time to complete this.

@ratkingsminion
Copy link

Please take as much time as you need, there is no hurry. Right now I'm just using a static variable as a workaround and it works well enough.

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