Closed n3urovirtual closed 2 years ago
Hi Christos, I’m currently on vacation so I can’t access the project. There’s a simple C# event that is triggered when you press the start experiment button. All you need to do is to trigger that same event through code or some other means to start the experiment. I can’t remember off the top of my head the name. But it’s probably something like TuxEvents.StartExperiment.
Sent from my iPhone
On Aug 8, 2021, at 2:06 PM, Christos Gkoumas @.***> wrote:
Hi,
I have built my project into an application and the scene environment is loaded properly while the UI to start the experiment is not. In the editor, everything works fine, as I have the scene environment on display 1 and the UI in display 2. I also managed to make it work with a WMR HMD (in the editor). I have read the "Building to an application" section on the bmltux website but it was not so informative on that matter. Is there a way to start the experiment after building a project? I was wondering if I could preload some scene environments (tasks) into a standalone VR HMD and have participants complete them without my assistance. Is this sth that could be done using the toolkit?
Many thanks and keep up the great work.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Did you get this working?
Hi Adam,
No, I didn't. I found the Events you were talking about but I couldn't get it to work. What I have now is this:
using bmlTUX.Scripts.Managers;
using bmlTUX.Scripts.ExperimentParts;
using UnityEngine;
using bmlTUX.Scripts.UI.RuntimeUI;
public class StartExperiment : MonoBehaviour
{
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space"))
{
Session session = new DebugSession();
Debug.Log("I am gonna make it work");
StartRunningExperiment(session);
}
}
void StartRunningExperiment(Session session)
{
ExperimentEvents.StartRunningExperiment(session);
}
}
Any help is much appreciated.
Right, so now that I'm home and looking at the code I'm seeing there's some complication there. Definitely not ideal. Let me take a look and get back to you
Sure. When I tried to track down what the issue was I remember having issues with referencing because some of the classes were not public. I don't know if this helps you somehow.
Ok so in the meantime, this seems to work. I will look into making this a bit more user friendly when I release the next version.
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space"))
{
Session session = new DebugSession();
//if you have participant variables
//foreach (ParticipantVariable variable in runner.DesignFile.GetVariables.ParticipantVariables) {
// variable.SetValueDefaultValue();
//}
ExperimentGui experimentStartPanel = FindObjectOfType<ExperimentGui>();
experimentStartPanel.gameObject.SetActive(false);
Debug.Log("I am gonna make it work");
StartRunningExperiment(session);
Destroy(this.gameObject);
}
}
Sorry, need to add the line Destroy(this.gameObject) to avoid spamming errors. I edited above post
Hi Adam,
Thanks for your prompt reply. Unfortunately, the code you posted doesn't work either. I am getting an error for ExperimentGui
and the StartRunningExperiment
method. Is this a namespace issue?
Update: ExperimentGui
error goes away if you add using bmlTUX.Scripts.UI.RuntimeUI;
Here are the namespaces I am using. Sorry, that's something else I need to fix, I forget that most of the world doesn't use Rider IDE.
using bmlTUX.Scripts.Managers; using bmlTUX.Scripts.ExperimentParts; using UnityEngine; using bmlTUX.Scripts.UI.RuntimeUI;
It still doesn't work. StartRunningExperiment
is red and says it does not exist in the current context. Also using bmlTUX.Scipts.Managers;
is gray like it is not being used in this script.
Do you have the script it in an assembly? Maybe you need to reference a different assembly? Or just put it directly in your assets folder with no assemblies? Or try rebooting Unity/your IDE.
it works for me with those using statements.
I added ExperimentEvents.StartRunningExperiment(session)
and it's fine now. I'm gonna test it using VR.
Update: It works in my WMR headset. Thanks a lot @AdamBebko!
Great! And thanks for the feedback, Hopefully I can clean up that workflow in the next version.
There is a new event for triggering the experiment to start based on a provided session
How to do this now:
Session session = new Session() //You create your session manually. Has to be a valid session.
ExperimentEvents.StartExperimentFromScript(session);
Behind the scenes:
//UI listens to this event and hides itself when it happens automatically.
public static event TriggerStartExperimentWithoutButtonEvent ExperimentTriggeredWithoutButton;
//Wraps call to StartRunningExperiment so rest of program can gracefully know that it's not happening from GUI.
[PublicAPI]
public static void StartExperimentFromScript(Session session)
{
ExperimentTriggeredWithoutButton?.Invoke(session);
StartRunningExperiment(session);
}
Hi,
I have built my project into an application and the scene environment is loaded properly while the UI to start the experiment is not. In the editor, everything works fine, as I have the scene environment on display 1 and the UI in display 2. I also managed to make it work with a WMR HMD (in the editor). I have read the "Building to an application" section on the bmltux website but it was not so informative on that matter. Is there a way to start the experiment after building a project? I was wondering if I could preload some scene environments (tasks) into a standalone VR HMD and have participants complete them without my assistance. Is this sth that could be done using the toolkit?
Many thanks and keep up the great work.