Question Can you modify an existing Plugin?

VamMoose

Well-known member
Messages
263
Reactions
358
Points
63
It's a simple question with, what I assume is a complicated answer.

There's a couple plugins which work pretty well, but aren't maintained anymore that I wish to tweak. I know the tweaking the code is complicated.

I know JavaScript, you can modify existing js files and it works runtime, but I think C# is a compiled language and you'd need the original source right?

Would appreciate any advice :)
 
While VaM can load compiled code in form of DLLs, I would guess >90% of the plugins floating around are just text files (*.cs). Those VaM compiles at runtime, e.g. when loading the scene. If a plugin consists of multiple files, they usually have a *.cslist file...which again is just a simple text file that lists all the files needed.

Most plugins will be in VAR packages, of course. However, you can unpack them using the "Unpack" button in VaM's package manager. Then you get a folder with the package name in your AddonPackage folder that contains the files. You can also unpack yourself, VAR packages are just ZIP files ;)
1682022278581.png
 
Upvote 0
Here is a trivial plugin that rotates the Atom you put it on:
C#:
using UnityEngine;

public class Rotate : MVRScript
{   
    protected void Update()
    {
        Transform t = containingAtom.mainController.transform;       
        float rotation = Time.deltaTime * 90.0f; // rotation speed: 90deg per second
        t.Rotate(0.0f, rotation, 0.0f);          // rotation axis: Y-Axis
    }
}
 
Upvote 0
Thank you very much for your response! This is promising.

My Focus is to enhance the MetaChat experience in any way I can. One plugin I use in one of my scene is the ProceduralChains plugin, so the "Update Link Count" button within the customUI could be triggered externally by a UIButton or something. I'll have to read up on how to do that because right now, it can't be triggered.

The other, is...well MetaChat itself (I'm not the dev) But the dev has gotten quite busy, and I would like to try my hand at branching off a version that continues the evolution.
 
Upvote 0
You could probably expose that method you want to call a trigger action, like this:

C#:
using UnityEngine;

public class ExposedActionTriggerExample : MVRScript
{
    public override void Init()
    {
        JSONStorableAction action = new JSONStorableAction("CallMyMethod", MyMethod);
        RegisterAction(action);
    }
  
    private void MyMethod()
    {
        SuperController.LogMessage("'MyMethod' was called. Do something here!");
    }
}

1682023247714.png


1682023322420.png
 
Upvote 0
Thanks again MacGruber, I appreciate it!

Would it be ok if I DM you another question? It is related to plugin coding, but it's a bit more big picture, and not too specific.
 
Upvote 0
Would it be ok if I DM you another question? It is related to plugin coding, but it's a bit more big picture, and not too specific.
You can DM, but I prefer disussions here in the forums, since others could benefit from my time spent on answering as well. It's simply more efficient than answering the same questions over and over. Also others might be able to help you quicker or correct me when I'm talking nonsense ;)
When sending DMs, keep in mind that I might decide to ignore you, or it might take several days for an answer. Think about what you want to know, forumulate it well, give some context, while at the same time don't throw a wall of text at me. My main issue is lack of time, so need to spend it efficently.

Edit: Let's forumulate it this way...if you want me to spend 20 or 30 minute of my precious free time on writing an answer that is actually correct and helpful (which might mean I need to actually try stuff in VaM, like the code above, etc).....then you might want to spend more than 30 seconds on formulating your question so at least I don't waste my time on answering things you don't want to know. (This may seem rather obvious, but sadly it appearently isn't to some people :ROFLMAO:)
 
Last edited:
Upvote 0
Thank you for your continued patience :)

I highly respect the time you and other talented individuals, and am willing to do as much learning on my part and contribute what I can :)

I've DM'd you the question in...question. No rush to answer at all.
 
Upvote 0
I have surprisingly found success with simply editing existing plugins by opening them with windows' built-in notepad. And by plugins, I mean I've really only tried this out on one.

MacGruber's PostMagic plugin, specifically the chromatic aberration feature, has an effect that wasn't strong enough for me. I simply opened up the file "MacGruber_ChromaticAberration.cs" and went to the line:

intensity = Utils.SetupSliderFloat(this, "Intensity", 0.1f, 0.0f, 1.0f, false);

to

intensity = Utils.SetupSliderFloat(this, "Intensity", 0.1f, 0.0f, 10.0f, false);

Which changed the range of the plugins' effect from 0-1 to 0-10, which brought me way closer to the intense trippy effect that I was looking for.

That's not to say that this method will work with other programs or anything, my experience with coding is extremely limited, I just took a wild guess and happened to be right.
 
Upvote 0
I'll leave the technical side of this question to others. But there are licensing and hub issues I'll address.

If you want to modify a plugin for your own use, you can do pretty much whatever you like.

But if you want to be able to share it, take a look at the license the original was distributed under. That will prescribe how or even if you will be allowed to share any derivative work. You can read about CC licensing here, or check out this more concise graphic showing the various terms.

License permitting, and assuming the original author is active, it would be polite to get in touch and let him know what you're planning before you post your modified version. If the original plugin is no longer being supported, and the author doesn't seem to be around any more, people are very much encouraged to go ahead and modify/update old plugins (again, license permitting) for the good of the community. Just be clear in your post that that's what you're doing, and credit the original author.

Finally, for security reasons, plugin creators are strongly encouraged to put out clear text plugins, rather than compiled DLL's. If that's not possible for the application you have in mind, contact one of the mods before you post it. At minimum, we'll need to add a warning to the post that any plugin containing an .exe or .dll may contain malicious code, and users download it at their own risk.
 
Upvote 0
Thanks very much DJ. Yes, I am overly cautious about the licencing issues with my uploads this far. Thanks for clarifying. I've already reached out to the original authors now that I've learned I can modify them. :)
 
Upvote 0
Back
Top Bottom