void ShowPreviewButton() { designFileTarget = target as ExperimentDesignFile2; if (GUILayout.Button("Preview Design", GUILayout.Height(50))) { DesignPreviewEditorWindow.ShowWindow(designFileTarget); } }
void CreateDesignFile() { ExperimentDesignFile2 file = CreateInstance <ExperimentDesignFile2>(); file.name = experimentName + DesignFileKey; AssetDatabase.CreateAsset(file, "Assets/" + file.name + ".asset"); AssetDatabase.SaveAssets(); EditorPrefs.SetString(DesignFileKey, file.name); }
ExperimentDesignFile2 CreateDesignFile() { string oldPath = AssetDatabase.GetAssetPath(target); ExperimentDesignFile2 file = CreateInstance <ExperimentDesignFile2>(); string fileName = Path.GetFileNameWithoutExtension(oldPath) + "_updated" + ".asset"; string path = Path.GetDirectoryName(oldPath); string fullPath = Path.Combine(path, fileName); string uniquePath = EditorGuiHelper.GetUniqueName(fullPath); Debug.Log(uniquePath); AssetDatabase.CreateAsset(file, uniquePath); AssetDatabase.SaveAssets(); return(file); }
void OnEnable() { variablePanelBackgroundColor = new Color(VariablePanelBackgroundLightness, VariablePanelBackgroundLightness, VariablePanelBackgroundLightness, 1); designFileTarget = target as ExperimentDesignFile2; if (designFileTarget == null) { Debug.LogError($"Null ExperimentDesignFile2 in editor {target.name}", this); throw new NullReferenceException("Null ExperimentDesignFile"); } factoryProp = serializedObject.FindProperty(nameof(ExperimentDesignFile2.Factory)); if (factoryProp == null) { throw new NullReferenceException("null factory prop"); } factory = designFileTarget.Factory; if (factory == null) { throw new NullReferenceException("null factory"); } trialTableGenerationMode = serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialTableGeneration)); orderConfigs = serializedObject.FindProperty(nameof(ExperimentDesignFile2.BlockOrderConfigurations)); blockRandomizationMode = serializedObject.FindProperty(nameof(ExperimentDesignFile2.BlockRandomization)); trialRandomizationMode = serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialRandomization)); trialRandomizationSubType = serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialPermutationType)); blockPartialRandomizationSubType = serializedObject.FindProperty(nameof(ExperimentDesignFile2.BlockPartialRandomizationSubType)); trialRepetitions = serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialRepetitions)); experimentRepetitions = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ExperimentRepetitions)); columnNameSettings = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ColumnNamesSettings)); controlSettings = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ControlSettings)); guiSettings = serializedObject.FindProperty(nameof(ExperimentDesignFile2.GuiSettings)); fileLocationSettings = serializedObject.FindProperty(nameof(ExperimentDesignFile2.FileLocationSettings)); showAdvanced = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ShowAdvancedEditor)); InitializeBlockOrderList(); selectedDataType = SupportedDataType.ChooseType; selectedVariableType = VariableType.ChooseType; }
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(); }