public void AddNew() { switch (VariableTypeToCreate) { case VariableType.Independent: { switch (DataTypesToCreate) { case SupportedDataTypes.Int: IndependentVariableInt ivInt = new IndependentVariableInt(); IntIVs.Add(ivInt); break; case SupportedDataTypes.Float: IndependentVariableFloat ivFloat = new IndependentVariableFloat(); FloatIVs.Add(ivFloat); break; case SupportedDataTypes.String: IndependentVariableString ivString = new IndependentVariableString(); StringIVs.Add(ivString); break; case SupportedDataTypes.Bool: IndependentVariableBool ivBool = new IndependentVariableBool(); BoolIVs.Add(ivBool); break; case SupportedDataTypes.GameObject: IndependentVariableGameObject ivGameObject = new IndependentVariableGameObject(); GameObjectIVs.Add(ivGameObject); break; case SupportedDataTypes.Vector3: IndependentVariableVector3 ivVector3 = new IndependentVariableVector3(); Vector3IVs.Add(ivVector3); break; case SupportedDataTypes.CustomDataType: IndependentVariableCustomDataType ivCustomDataType = new IndependentVariableCustomDataType(); CustomDataTypeIVs.Add(ivCustomDataType); break; case SupportedDataTypes.ChooseType: throw new InvalidEnumArgumentException("Trying to create new variable, but not types not yet chosen"); default: throw new NotImplementedException("Support for this BlockData types has not yet been defined." + "You can customize it yourself in the IndependentVariable.cs class"); } } break; case VariableType.Dependent: switch (DataTypesToCreate) { case SupportedDataTypes.Int: DependentVariableInt newDependentVariableInt = new DependentVariableInt(); IntDVs.Add(newDependentVariableInt); break; case SupportedDataTypes.Float: DependentVariableFloat newDependentVariableFloat = new DependentVariableFloat(); FloatDVs.Add(newDependentVariableFloat); break; case SupportedDataTypes.String: DependentVariableString newDependentVariableString = new DependentVariableString(); StringDVs.Add(newDependentVariableString); break; case SupportedDataTypes.Bool: DependentVariableBool newDependentVariableBool = new DependentVariableBool(); BoolDVs.Add(newDependentVariableBool); break; case SupportedDataTypes.GameObject: DependentVariableGameObject newDependentVariableGameObject = new DependentVariableGameObject(); GameObjectDVs.Add(newDependentVariableGameObject); break; case SupportedDataTypes.Vector3: DependentVariableVector3 newDependentVariableVector3 = new DependentVariableVector3(); Vector3DVs.Add(newDependentVariableVector3); break; case SupportedDataTypes.CustomDataType: DependentVariableCustomDataType newDependentVariableCustomDataType = new DependentVariableCustomDataType(); CustomDataTypeDVs.Add(newDependentVariableCustomDataType); break; case SupportedDataTypes.ChooseType: throw new InvalidEnumArgumentException("Trying to create new variable, but not types not yet chosen"); default: throw new NotImplementedException("Support for this BlockData types has not yet been defined." + "You can customize it yourself in the IndependentVariable.cs class"); } break; case VariableType.ChooseType: break; case VariableType.Participant: switch (DataTypesToCreate) { case SupportedDataTypes.Int: ParticipantVariableInt newVariableInt = new ParticipantVariableInt(); IntParticipantVariables.Add(newVariableInt); break; case SupportedDataTypes.Float: ParticipantVariableFloat newVariableFloat = new ParticipantVariableFloat(); FloatParticipantVariables.Add(newVariableFloat); break; case SupportedDataTypes.String: ParticipantVariableString newVariableString = new ParticipantVariableString(); StringParticipantVariables.Add(newVariableString); break; case SupportedDataTypes.Bool: ParticipantVariableBool newVariableBool = new ParticipantVariableBool(); BoolParticipantVariables.Add(newVariableBool); break; case SupportedDataTypes.GameObject: ParticipantVariableGameObject newVariableGameObject = new ParticipantVariableGameObject(); GameObjectParticipantVariables.Add(newVariableGameObject); break; case SupportedDataTypes.Vector3: ParticipantVariableVector3 newVariableVector3 = new ParticipantVariableVector3(); Vector3ParticipantVariables.Add(newVariableVector3); break; case SupportedDataTypes.CustomDataType: ParticipantVariableCustomData newVariableCustomData = new ParticipantVariableCustomData(); CustomDataParticipantVariables.Add(newVariableCustomData); break; case SupportedDataTypes.ChooseType: throw new InvalidEnumArgumentException("Trying to create new variable, but not types not yet chosen"); default: throw new NotImplementedException("Support for this BlockData types has not yet been defined." + "You can customize it yourself in the IndependentVariable.cs class"); } break; default: throw new ArgumentOutOfRangeException(nameof(VariableTypeToCreate), DataTypesToCreate, null); } }
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(); }