Session plugin behaviors?

cmramlow

Active member
Messages
209
Reactions
82
Points
28
The wiki seems to be missing any details on the session plugins or expected behaviors - (1) UI_Complete | Virt-A-Mate Hub (virtamate.com)

Does any coders know the answer to any of these:

1 - if having a var based or loose file scripts set in as a session plugin BUT unchecked so it's supposed to not load, is the expected behavior is some type of minimal preload anyway?

2 - which session plugin load order takes preference if there's a conflicting vam behavior change, for instance, in session plugin slot 1 a script changes the eyes blue but in session plugin slot 10 the eyes get changed black - which one takes precedence?

Thank you
 
1 - if having a var based or loose file scripts set in as a session plugin BUT unchecked so it's supposed to not load, is the expected behavior is some type of minimal preload anyway?
I would assume so you get a call order like this:
  • OnEnable()
  • Init()
  • LateRestoreFromJSON()
  • OnDisable()
Update() won't be called, of course. Best way to be certain is to actually try ;)

2 - which session plugin load order takes preference if there's a conflicting vam behavior change, for instance, in session plugin slot 1 a script changes the eyes blue but in session plugin slot 10 the eyes get changed black - which one takes precedence?
Whoever sets things last, obviously. In the Unity engine updates are done in order of the execution order value of the scripts. They all default to 0. For scripts with the same execution order value, the update order is not defined...aka it's "random". Meaning that you should not rely on it. However you can explicitly define the execution order value using the DefaultExecutionOrder attribute. Updates are just sorted by that value. Negative values go before default updates, positive ones after.

Then there is also LateUpdate. It's a second round of updates for all scripts in the scene. So, you got first calls to Update() in execution order, then a second round with calls to LateUpdate() also in execution order.

Note that Update order does not affect calls to OnEnable/OnDisable or Init(). Write your code in a way that does not rely on their order.

C#:
using UnityEngine;

namespace MacGruber
{
    [DefaultExecutionOrder(100)]
    public class CameraLock : MVRScript
    {
        public override void Init()
        {
        }

        private void Update()
        {
        }

        private void LateUpdate()
        {
        }
    }
}
 
Hey @MacGruber! Wow, a script answer from the scripting MASTER 😲

"Update() won't be called, of course. Best way to be certain is to actually try ;)"

1- Does this assume I know anything about coding 🙃 You give too much credit but thank you.

To clarify, I'll never be able to code, I'm just not fine details friendly enough 😔 so I'm trying to learn enough to understand where, out of 31 session plugins is the best place for some of the session plugins, and I don't know how to test or try (but would LOVE to - what steps do lean enough to test this as you recommend?) and what does these do:
  • OnEnable() - (I assume this means if the plugin gets enabled by checking the box)
  • Init() - (I assume this means the plugin is enabled and is executed in turn)
  • LateRestoreFromJSON() - (what does this mean or when does this occur?)
  • OnDisable() - (I assume this means if the plugin gets disabled by un-checking the box)
***Let's say I have all 31 session plugins set from 0 to 30 in my session plugin slots and the all have the explicitly defined execution order value using the DefaultExecutionOrder attribute to load when their number in the order of 31 is called, does session plugin 0 get launched first or is it the 30th?

Thank you!
 
Does this assume I know anything about coding 🙃 You give too much credit but thank you.
In that case you probably should not modfiy plugins to mess with execution order, you will just break things.

out of 31 session plugins is the best place for some of the session plugins
Seriously....31 session plugins?
Sounds like a XY problem here? We talk about your solution Y....what is the underlining thing X you want to achieve.
 
Yes, 31 where a few of the lot are from this one tremendously creative coding genius I have unrivalled awe and admiration for, who's name is MacGruber, not Mcgruber, which I've inadvertently referred to him a few times out of ignorance and dumb mistake.

The goal is to bend VAM to my will to perform exactly how I need. I've been utilizing VAM since it was first released many years ago and have sunk a tumultuous many 100's of hours into it as much as I have spent 100's of dollars paying for Patreon guides and goods as well as hiring a personal VAM/Unity scripter to create unseen and unheard of programs and plugins that some said couldn't be done, such as a plugin where you can drag/drop fully rearrange the entire plugin preset menu and search through my often 30+ person atom plugin sets arrayed in any glorious bursting preset menus.....

So, this is the origin and logic of this post, to better understand VAM's session plugin loading nuances since I know when there's more than one session plugin being called upon load it likely would benefit to execute in a certain load order to avoid and overwrite script change conflict and ensure the primary desired plugin induced affect is an assured outcome based on load order manipulation.
 
So, this is the origin and logic of this post, to better understand VAM's session plugin loading nuances since I know when there's more than one session plugin being called upon load it likely would benefit to execute in a certain load order to avoid and overwrite script change conflict and ensure the primary desired plugin induced affect is an assured outcome based on load order manipulation.
Session plugins have all their own GameObject. Hence, as I explained above the update order is not defined for scripts that have the same ExecutionOrder.
I think initialization order isn't defined either. Did a dive in VaM's codebase for this. VaM somehow stores the plugins in order, there must be a sort somewhere I can't find. However, it uses uses SimpleJSON to load the data, which uses a C# Dictionary, which is a HashMap. Plugins appear to be loaded in order of that HashMap, which is "random" (due to the hashing)
C#:
JSONClass asObject = jc["plugins"].AsObject;
List<MVRPlugin> list = new List<MVRPlugin>();
if (asObject != null)
{
   foreach (string key in asObject.Keys)
   {
       MVRPlugin mVRPlugin = CreatePluginWithId(key);
       pluginUIDs.Add(key, value: true);
       list.Add(mVRPlugin);
       mVRPlugin.pluginURLJSON.RestoreFromJSON(asObject);
   }
}

For reference, look at the implementation of MVRPluginManager.LateRestoreFromJSON.


TL;DR: You can't rely on the order of things. You have to make sure you setup can handle any order. Most obvious solution is to simply to not have multiple things changing eye color (that was your example in the first post). Because that is inefficient anyway.
The other obvious solution is to use a single (or very few) specialized plugin giving you fully control over the order, rather than >30 general purpose plugins.
 
Back
Top Bottom