• Hi Guest!

    We are extremely excited to announce the release of our first Beta1.1 and the first release of our Public AddonKit!
    To participate in the Beta, a subscription to the Entertainer or Creator Tier is required. For access to the Public AddonKit you must be a Creator tier member. Once subscribed, download instructions can be found here.

    Click here for information and guides regarding the VaM2 beta. Join our Discord server for more announcements and community discussion about VaM2.
  • Hi Guest!

    VaM2 Resource Categories have now been added to the Hub! For information on posting VaM2 resources and details about VaM2 related changes to our Community Forums, please see our official announcement here.

Solved [SCRIPTING] Does anybody know the code/script to add a script to an Atom using a script?

whymeazn

New member
Joined
Sep 27, 2020
Messages
8
Reactions
0
So say I create Atom AudioSource using code, and I add it to the scene. How does one attach a script to this AudioSource to it, such as soundRandomizer.cs into it, via using it scripts? What is the code/syntax for it?
 
Solution
Never tried this, but some bits as a starting point to dig into. Remember, you can look at VaMs codebase with ILSpy to figure out the details:
  • Every atom has a JSONStorable named "PluginManager", which should be a MVRPluginManager object.
  • Calling CreatePlugin() on the MVRPluginManager should give you a MVRPlugin object.
  • Setting plugin.pluginURLJSON.val = "Custom/Scripts/YourFancyPluginHere.cs"; should cause the plugin to be compiled and loaded.
Never tried this, but some bits as a starting point to dig into. Remember, you can look at VaMs codebase with ILSpy to figure out the details:
  • Every atom has a JSONStorable named "PluginManager", which should be a MVRPluginManager object.
  • Calling CreatePlugin() on the MVRPluginManager should give you a MVRPlugin object.
  • Setting plugin.pluginURLJSON.val = "Custom/Scripts/YourFancyPluginHere.cs"; should cause the plugin to be compiled and loaded.
 
Upvote 0
Solution
Ah I see, I think I have a better understanding now - also one example I've seen used is AutoMate when it automatically loads plugins to the Person Atom or Session on load.
 
Upvote 0
Back
Top Bottom