// Start is called before the first frame update void Start() { initialImportDicomScript = this.GetComponent <initialImportDicom>(); savedDirectoryFilePath = Path.Combine(dicomAssetPath, savedDirectoryFileName); //Debug.Log(savedDirectoryFilePath); //LOAD DIRECTORY PATH if (savedDirectoryFilePath != null) { var resource = Resources.Load <TextAsset>(savedDirectoryFilePath); if (resource != null) { savedDirectoryFileNames = resource.text; //Debug.Log(savedDirectoryFileNames); } } //DESERIALIZE DIRECTORY NAMES if (savedDirectoryFileNames != null) { XmlSerializer deserializer = new XmlSerializer(typeof(string[])); using (StringReader reader = new StringReader(savedDirectoryFileNames)) { object obj = deserializer.Deserialize(reader); savedDirectoryNames = (string[])obj; //Debug.Log(savedDirectoryNames); } } buttonTemplate = transform.GetChild(0).gameObject; //CREATE ONE BUTTON IN LIST FOR EVERY IMPORTED DIRECTORY if (savedDirectoryNames != null) { for (int i = 0; i < savedDirectoryNames.Length; i++) { newButton = Instantiate(buttonTemplate, transform); newButton.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = $"{savedDirectoryNames[i]}"; newButton.GetComponent <Button>().AddEventListener(i, ButtonClicked); } Destroy(buttonTemplate); } scrollView.verticalNormalizedPosition = 1; }
static void Apply() { string path = EditorUtility.OpenFolderPanel("Load Dicom Directory", "", ""); //CHECK IF FOLDER EMPTY AND SET FOLDER PATH if (path.Length != 0) { dicomImporter = GameObject.Find("Dicom_Importer"); initialImportScript = dicomImporter.GetComponent <initialImportDicom>(); initialImportScript.userDefinedDicomPath = path; initialImportScript.userDefinedFolderName = path.Split(Path.DirectorySeparatorChar).Last(); } }
public override void OnInspectorGUI() { //LABELS EditorGUILayout.LabelField("To choose Directory containing dicom files, go up to menu bar"); EditorGUILayout.LabelField("and select menu: MediVR/Choose Dicom Source Directory."); EditorGUILayout.Space(); EditorGUILayout.Space(); //DEFAULT LAYOUT DrawDefaultInspector(); EditorGUILayout.Space(); //LABELS EditorGUILayout.LabelField("Slices must be ordered from distal to proximal end of volume."); EditorGUILayout.LabelField("If in reverse order, check box Reverse Slice Order."); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Press Button to Create a 3D Texture from files at directory."); EditorGUILayout.LabelField("The 3D Texture will be saved as an Asset for use at runtime."); EditorGUILayout.Space(); //BUTTONS initialImportDicom import = (initialImportDicom)target; if (GUILayout.Button("Import Dicom Files")) { import.CreateTexture3DAssets(); } if (GUILayout.Button("Save Imported Directory Names")) { import.SaveImportedTextureDirectoryNames(); } }