» VL Dynamic instancing without Delegates
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

VL Dynamic instancing without Delegates

demo reflection

about

Hi!

I was wondering how to instance an arbitrary object based on its type name in VL for a while.

For now I offer this solution that uses the built-in Deserialize functionality, inspired by the arbitrary object spread demo in the VL Serialization help patch.

Although not perfect (any object you expect to instance has to be explicitly used in the patch (inspired by elias's LINK experience)), it's the closest solution I know of until this functionality gets native support. Is it better than Delegates with a Dictionary? You decide!

Any simplification tips appreciated.

Until next time!

Elias 21/01/2019 - 16:12

Hey Dominik,
nice to put this out there. I'll report back once I get to VL and dynamic instantiation again.

microdee 22/01/2019 - 11:26

Is there a limitation of why Activator.CreateInstance wouldn't work in vl? at least it should work in script region https://docs.microsoft.com/en-us/dotnet/api/system.activator.createinstance?view=netframework-4.7.2

also for more reflection goodies check out fasterflect https://github.com/buunguyen/fasterflect ;)

Elias 23/01/2019 - 11:31

CteateInstance should also work but maybe little tricky to know what values to feed for the arguments. Would be easier if a default ctor would be present in target code.

anonymous user login

Shoutbox

~2d ago

joreg: absolutely. if it is for a repo that is public, just submit a pullrequest. otherwise please start a forum thread.

~2d ago

benjawmino: @joreg I ended up figuring out BezierSegment yesterday, so nevermind! Tell me, could a user submit a help patch? :)

~2d ago

joreg: @benjawmino please elaborate on this question a bit in a new forum thread. otherwise it is hard to answer..

~4d ago

benjawmino: so are there no splines/curves in gamma yet??

~7d ago

skyliner: wanna do drone shows or applications? then check this super cool project of our man e1n

~11d ago

NoseBleedIndustries: Thanks Joreg! The few minutes I was able to see, very good workshops!

~11d ago

joreg: @NoseBleedIndustries please give us some days, we'll have an announcement soon...

~11d ago

NoseBleedIndustries: I could not assist the Node20 (workshops ) Any Idea when we will have access to the links of the recordings?

~13d ago

bjoern: unity has c# bindings for usd, under apache license: https://github.com/Unity-Technologies/usd-unity-sdk