• Hi Guest!

    We are extremely excited to announce the release of our first Beta for VaM2, the next generation of Virt-A-Mate which is currently in development.
    To participate in the Beta, a subscription to the Entertainer or Creator Tier is required. 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.

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