void SetupConstrainedValues(ParticipantVariable participantVariable) { List <string> possibleValues = participantVariable.PossibleValuesStringArray.ToList(); possibleValues.Insert(0, SelectText); Dropdown.options.Clear(); foreach (string value in possibleValues) { Dropdown.options.Add(new TMP_Dropdown.OptionData() { text = value }); } }
public DataTable AddValuesToCopyOf(DataTable table, ParticipantVariable <T> participantVariable) { AddVariableColumn(participantVariable, table); if (table.Rows.Count == 0) { throw new ArgumentException("Can't add participant variable values to empty trialTable"); } foreach (DataRow newTableRow in table.Rows) { newTableRow[participantVariable.Name] = participantVariable.Value; } return(table); }
public void Display(ParticipantVariable participantVariable) { Variable = participantVariable; Label.text = participantVariable.Name; if (participantVariable.ValuesAreConstrained) { ConfirmValueMethod = ConstrainedGetValueStrategy; Dropdown.gameObject.SetActive(true); SetupConstrainedValues(participantVariable); } else { ValueInput.gameObject.SetActive(true); ConfirmValueMethod = DefaultGetValueStrategy; } }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.HelpBox("This Design file was created using an older version. Please Update it now. You may lose some settings", MessageType.Warning); ExperimentDesignFile old = target as ExperimentDesignFile; if (old == null) { throw new NullReferenceException("Can't retrieve old experiment design file"); } if (GUILayout.Button("Update now")) { ExperimentDesignFile2 newFile = CreateDesignFile(); newFile.Factory.IndependentVariables = old.Factory.IndependentVariables; newFile.Factory.DependentVariables = old.Factory.DependentVariables; newFile.Factory.ParticipantVariables = old.Factory.ParticipantVariables; newFile.ControlSettings = old.ControlSettings; newFile.GuiSettings = old.GuiSettings; newFile.ColumnNamesSettings = old.ColumnNamesSettings; newFile.FileLocationSettings = old.FileLocationSettings; newFile.TrialRandomization = old.TrialRandomization; newFile.TrialRepetitions = old.TrialRepetitions; newFile.TrialPermutationType = old.TrialPermutationType; newFile.BlockRandomization = old.BlockRandomization; newFile.BlockPartialRandomizationSubType = old.BlockPartialRandomizationSubType; newFile.ExperimentRepetitions = old.ExperimentRepetitions; foreach (Variable variable in newFile.Factory.ParticipantVariables) { ParticipantVariable participantVariable = variable as ParticipantVariable; participantVariable.DataType = ConvertOldDataType(participantVariable.DataType); participantVariable.ConvertOldValues(); } } EditorGUILayout.LabelField("IVs:"); EditorGUI.indentLevel++; foreach (Variable variable in old.Factory.IndependentVariables) { EditorGUILayout.LabelField($"{variable.Name}, type {variable.DataType}"); IndependentVariable iv = variable as IndependentVariable; List <string> values = iv.ValuesAsString(); EditorGUI.indentLevel++; foreach (string value in values) { EditorGUILayout.LabelField(value); } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; EditorGUILayout.LabelField("DVs:"); EditorGUI.indentLevel++; foreach (Variable variable in old.Factory.DependentVariables) { EditorGUILayout.LabelField($"{variable.Name}, type {variable.DataType}"); } EditorGUI.indentLevel--; EditorGUILayout.LabelField("PVs:"); EditorGUI.indentLevel++; foreach (Variable variable in old.Factory.ParticipantVariables) { EditorGUILayout.LabelField($"{variable.Name}, type {ConvertOldDataType(variable.DataType)}"); } EditorGUI.indentLevel--; serializedObject.ApplyModifiedProperties(); }
void ShowParticipantVariables() { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Fill In Participant Variables:", EditorStyles.boldLabel); List <Variable> variables = runner.ConfigFile.Factory.AllVariables; foreach (Variable variable in variables) { if (variable.TypeOfVariable != VariableType.Participant) { continue; } ParticipantVariable participantVariable = (ParticipantVariable)variable; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(participantVariable.Name + ":", LabelWidth); if (participantVariable.ValuesAreConstrained) { string[] possibleValues = participantVariable.PossibleValuesStringArray; participantVariable.SelectedValue = EditorGUILayout.Popup(participantVariable.SelectedValue, possibleValues); } else { switch (participantVariable.DataType) { case SupportedDataTypes.Int: ParticipantVariableInt intVariable = (ParticipantVariableInt)participantVariable; intVariable.Value = EditorGUILayout.IntField(intVariable.Value); break; case SupportedDataTypes.Float: ParticipantVariableFloat floatVariable = (ParticipantVariableFloat)participantVariable; floatVariable.Value = EditorGUILayout.FloatField(floatVariable.Value); break; case SupportedDataTypes.String: ParticipantVariableString stringVariable = (ParticipantVariableString)participantVariable; stringVariable.Value = EditorGUILayout.TextField(stringVariable.Value); break; case SupportedDataTypes.Bool: ParticipantVariableBool boolVariable = (ParticipantVariableBool)participantVariable; boolVariable.Value = EditorGUILayout.Toggle(boolVariable.Value); break; case SupportedDataTypes.GameObject: case SupportedDataTypes.Vector3: case SupportedDataTypes.CustomDataType: case SupportedDataTypes.ChooseType: break; default: throw new ArgumentOutOfRangeException(); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
//Sort Independent variables into mixing categories so they go in order public SortedVariableContainer(List <Variable> allData, bool block) { int numberOfBlockIvs = 0; int numberOfNonBlockIvs = 0; foreach (Variable variable in allData) { if (variable.TypeOfVariable == VariableType.Independent) { IndependentVariable independentVariable = (IndependentVariable)variable; if (independentVariable.Block) { numberOfBlockIvs++; } else { numberOfNonBlockIvs++; } if (block && independentVariable.Block || !block && !independentVariable.Block) { switch (independentVariable.MixingTypeOfVariable) { case VariableMixingType.Balanced: BalancedIndependentVariables.Add(independentVariable); break; case VariableMixingType.Looped: LoopedIndependentVariables.Add(independentVariable); break; case VariableMixingType.EvenProbability: case VariableMixingType.CustomProbability: ProbabilityIndependentVariables.Add(independentVariable); break; default: throw new ArgumentOutOfRangeException(); } } } else if (variable.TypeOfVariable == VariableType.Dependent) { DependentVariable dependentVariable = (DependentVariable)variable; DependentVariables.Add(dependentVariable); } else if (variable.TypeOfVariable == VariableType.Participant) { ParticipantVariable participantVariable = (ParticipantVariable)variable; ParticipantVariables.Add(participantVariable); } } bool thereAreBlockIvsButNoNormalIvs = numberOfBlockIvs > 0 && numberOfNonBlockIvs == 0; if (!block && thereAreBlockIvsButNoNormalIvs) { throw new ExperimentDesign.InvalidExperimentDesignException($"You defined {numberOfBlockIvs} block variable(s), " + $"when there are {numberOfNonBlockIvs} unblocked independent variables." + $"You can safely unblock the variable " + $"to make it a normal variable"); } }