public IEnumerable <KeyValuePair <string, string> > ToParameters() { if (Mode != default) { yield return(new KeyValuePair <string, string>("mode", Mode.ToString())); } if (Format != null) { yield return(new KeyValuePair <string, string>("format", Format.ToString())); } if (TargetWidth != null) { yield return(new KeyValuePair <string, string>("targetWidth", TargetWidth.ToString())); } if (TargetHeight != null) { yield return(new KeyValuePair <string, string>("targetHeight", TargetHeight.ToString())); } if (Quality != null) { yield return(new KeyValuePair <string, string>("quality", Quality.ToString())); } if (FocusX != null) { yield return(new KeyValuePair <string, string>("focusX", FocusX.ToString())); } if (FocusY != null) { yield return(new KeyValuePair <string, string>("focusY", FocusY.ToString())); } if (Background != null) { yield return(new KeyValuePair <string, string>("background", Background)); } if (ExtraParameters != null) { foreach (var kvp in ExtraParameters) { yield return(kvp); } } }
new void Start() { base.Start(); PrepareOffScreenRay(); experiment = new ExperimentControl("RingSelection"); experiment.DepthPlane = TargetSet; experiment.Camera = EPSONcamera.GetComponent <Camera>(); experiment.LeftEyeCamera = LeftEyeCamera; experiment.Settings = cSettings; experiment.BaseFolder = BaseFolder; experiment.ParticipantNro = ParticipantNro; all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), TargetDistance.ToString()); IndexInitialTargets(); CreateInitialLayout(); }
private void server_CreateNewTarget() { lastTarget = targets[currentTarget].gameObject; int nextTarget = currentTarget + 8; if (experiment.Trial.TrialNro % 2 == 1) { nextTarget++; } nextTarget = nextTarget % targets.Count; bool doneAllDists = true; bool doneAllWidths = true; foreach (bool done in doneDistances) { if (!done) { doneAllDists = false; } } foreach (bool done in doneWidths) { if (!done) { doneAllWidths = false; } } experiment.Trial.TrialNro++; if (experiment.Trial.TrialNro == NumberOfTrials) { if (doneAllWidths && doneAllDists)//&& doneZones[1] && doneZones[2]) //all zones are done, experiment finishes { nextTarget = -1; all_SetTargetAndTrial(-1, -1); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SetTargetAndTrial", RPCMode.Others, -1, -1); } GameObject osStart1 = TargetSet; GameObject osEnd1 = TargetSet; all_SynchOffScreenTargets(osStart1.name, osEnd1.name); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SynchOffScreenTargets", RPCMode.Others, osStart1.name, osEnd1.name); } Screen.lockCursor = false; return; } else { // Change width, reset distances if (doneAllDists && !doneAllWidths) { TargetWidths newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length); while (doneWidths[(int)newWidth]) { newWidth = (TargetWidths)UnityEngine.Random.Range(0, doneWidths.Length); } all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), newWidth.ToString(), TargetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), newWidth.ToString(), TargetDistance.ToString()); } doneWidths[(int)newWidth] = true; for (int dist = 0; dist < doneDistances.Length; dist++) { doneDistances[dist] = false; // Do not do distances that will put targets out of view in view based. if (RefFrame == ReferenceFrame.View && dist > 1) { doneDistances[dist] = true; } // Do not do distances that are all in view else if (RefFrame == ReferenceFrame.Body && dist < 2) { doneDistances[dist] = true; } } } // Change distance keep width else { TargetDistances newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length); while (doneDistances[(int)newDistance]) { newDistance = (TargetDistances)UnityEngine.Random.Range(0, doneDistances.Length); } all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), newDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), newDistance.ToString()); } doneDistances[(int)newDistance] = true; } } nextTarget = UnityEngine.Random.Range(0, targets.Count); experiment.Trial.TrialNro = 0; } all_SetTargetAndTrial(nextTarget, experiment.Trial.TrialNro); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SetTargetAndTrial", RPCMode.Others, nextTarget, experiment.Trial.TrialNro); } //creates the offscreen targeting objects GameObject osStart2 = lastTarget; GameObject osEnd2 = targets[currentTarget].gameObject; all_SynchOffScreenTargets(osStart2.name, osEnd2.name); if (Network.isServer) { //if (Network.isClient || Network.isServer) networkView.RPC("all_SynchOffScreenTargets", RPCMode.Others, osStart2.name, osEnd2.name); } }
void OnGUI() { if (!ShowGUI && GUILayout.Button("Show Controls", GUILayout.Width(100), GUILayout.Height(30))) { ShowGUI = true; } else if (ShowGUI && GUILayout.Button("Hide Controls", GUILayout.Width(100), GUILayout.Height(30))) { ShowGUI = false; } CommToAndroid.Instance.ShowGUI = ShowGUI; NetworkProvider.Instance.ShowGUI = ShowGUI; RotationProvider.Instance.ShowGUI = ShowGUI; cSettings.RaycastController.ShowGUI = ShowGUI; if (ShowGUI) { if (GUILayout.Button("Start", GUILayout.Width(100), GUILayout.Height(30))) { //starts the experiment on the desktop (server) or when it's standalone if (!NetworkProvider.Instance.isConnected || Network.isServer) { server_StartExperiment(); Screen.lockCursor = true; } else { networkView.RPC("server_StartExperiment", RPCMode.Server); } } // GUI for changing reference frames(view/body/world) GUILayout.BeginArea(new Rect(0, 65, 50, 150)); System.Array refFrames = System.Enum.GetValues(typeof(ReferenceFrame)); GUILayout.Label("RefFrame:", GUILayout.Width(100), GUILayout.Height(20)); foreach (ReferenceFrame refFrame in refFrames) { bool isCurrent = refFrame == RefFrame; if (GUILayout.Toggle(isCurrent, refFrame.ToString(), GUILayout.Width(100), GUILayout.Height(25)) && !isCurrent) //-- this last piece is VERY important { //calls both the remote and the local method all_UpdateReferenceFrame(Zone.ToString(), refFrame.ToString(), TargetWidth.ToString(), TargetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), refFrame.ToString(), TargetWidth.ToString(), TargetDistance.ToString()); } } } GUILayout.EndArea(); // GUI for changing parameters(width/amplitude) GUILayout.BeginArea(new Rect(60, 65, 50, 200)); System.Array targetWidths = System.Enum.GetValues(typeof(TargetWidths)); GUILayout.Label("TargetWidth:", GUILayout.Width(100), GUILayout.Height(20)); foreach (TargetWidths targetWidth in targetWidths) { bool isCurrent = targetWidth == TargetWidth; if (GUILayout.Toggle(isCurrent, targetWidth.ToString(), GUILayout.Width(100), GUILayout.Height(25)) && !isCurrent) //-- this last piece is VERY important { //calls both the remote and the local method all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), targetWidth.ToString(), TargetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), targetWidth.ToString(), TargetDistance.ToString()); } } } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(120, 65, 50, 200)); System.Array targetDistances = System.Enum.GetValues(typeof(TargetDistances)); GUILayout.Label("TargetDistance:", GUILayout.Width(100), GUILayout.Height(20)); foreach (TargetDistances targetDistance in targetDistances) { bool isCurrent = targetDistance == TargetDistance; if (GUILayout.Toggle(isCurrent, targetDistance.ToString(), GUILayout.Width(100), GUILayout.Height(25)) && !isCurrent) //-- this last piece is VERY important { //calls both the remote and the local method all_UpdateReferenceFrame(Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), targetDistance.ToString()); if (Network.isClient || Network.isServer) { networkView.RPC("all_UpdateReferenceFrame", RPCMode.OthersBuffered, Zone.ToString(), RefFrame.ToString(), TargetWidth.ToString(), targetDistance.ToString()); } } } GUILayout.EndArea(); } GUILayout.BeginArea(new Rect(Screen.width - 100, Screen.height - 100, 100, 100)); GUILayout.Label("Trial " + (experiment.Trial.TrialNro + 1) + "/" + NumberOfTrials, GUILayout.Width(100), GUILayout.Height(20)); GUILayout.EndArea(); }