public static SelectionList ( int selected, GUIContent list ) : int | ||
selected | int | |
list | GUIContent | |
리턴 | int |
public void OnGUI() { GUILayout.BeginArea( m_screenRect, m_name, GUI.skin.window ); GUILayout.BeginHorizontal(); for (int parentIndex = 0; parentIndex < m_currentDirectoryParts.Length; ++parentIndex) { if (parentIndex == m_currentDirectoryParts.Length - 1) { GUILayout.Label(m_currentDirectoryParts[parentIndex], CentredText); } else if (GUILayout.Button(m_currentDirectoryParts[parentIndex])) { string parentDirectoryName = m_currentDirectory; for (int i = m_currentDirectoryParts.Length - 1; i > parentIndex; --i) { parentDirectoryName = Path.GetDirectoryName(parentDirectoryName); } SetNewDirectory(parentDirectoryName); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.box ); m_selectedDirectory = GUILayoutx.SelectionList( m_selectedDirectory, m_directoriesWithImages, DirectoryDoubleClickCallback ); if (m_selectedDirectory > -1) { m_selectedFile = m_selectedNonMatchingDirectory = -1; } m_selectedNonMatchingDirectory = GUILayoutx.SelectionList( m_selectedNonMatchingDirectory, m_nonMatchingDirectoriesWithImages, NonMatchingDirectoryDoubleClickCallback ); if (m_selectedNonMatchingDirectory > -1) { m_selectedDirectory = m_selectedFile = -1; } GUI.enabled = BrowserType == FileBrowserType.File; m_selectedFile = GUILayoutx.SelectionList( m_selectedFile, m_filesWithImages, FileDoubleClickCallback ); GUI.enabled = true; if (m_selectedFile > -1) { m_selectedDirectory = m_selectedNonMatchingDirectory = -1; } GUI.enabled = false; GUILayoutx.SelectionList( -1, m_nonMatchingFilesWithImages ); GUI.enabled = true; GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); UIData.loadHireRNA = GUILayout.Toggle(UIData.loadHireRNA, "HiRERNA model"); UIData.readHetAtom = GUILayout.Toggle(UIData.readHetAtom, "Read HetAtm?"); UIData.readWater = GUILayout.Toggle(UIData.readWater, "Read Water?"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(buttonWidth))) { m_callback(null); } if (BrowserType == FileBrowserType.File) { GUI.enabled = m_selectedFile > -1; } else { if (SelectionPattern == null) { GUI.enabled = m_selectedDirectory > -1; } else { GUI.enabled = m_selectedDirectory > -1 || ( m_currentDirectoryMatches && m_selectedNonMatchingDirectory == -1 && m_selectedFile == -1 ); } } if (GUILayout.Button("Select", GUILayout.Width(buttonWidth))) { if (BrowserType == FileBrowserType.File) { m_callback(Path.Combine(m_currentDirectory, m_files[m_selectedFile])); } else { if (m_selectedDirectory > -1) { m_callback(Path.Combine(m_currentDirectory, m_directories[m_selectedDirectory])); } else { m_callback(m_currentDirectory); } } } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.EndArea(); if (Event.current.type == EventType.Repaint) { SwitchDirectoryNow(); } }
public void OnGUI() { GUILayout.BeginArea(m_screenRect, "", GUI.skin.window); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.Label("Select song", CentredText); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); if (!selectDrive) { GameObject.Find("FolderButton").SetActive(true); selectDrive = true; for (int parentIndex = 0; parentIndex < m_currentDirectoryParts.Length; parentIndex++) { if (m_currentDirectoryParts.Length == 1) { GUI.enabled = false; GUILayout.Button(m_currentDirectoryParts[0]); GUI.enabled = true; } else { if (parentIndex == m_currentDirectoryParts.Length - 1) { GUI.enabled = false; GUILayout.Button(m_currentDirectoryParts[parentIndex]); GUI.enabled = true; } else if (GUILayout.Button(m_currentDirectoryParts[parentIndex])) { string parentDirectoryName = m_currentDirectory; for (int i = m_currentDirectoryParts.Length - 1; i > parentIndex; --i) { parentDirectoryName = Path.GetDirectoryName(parentDirectoryName); } SetNewDirectory(parentDirectoryName); } } } } else { GUI.enabled = false; GUILayout.Button("Computer"); GUI.enabled = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); m_scrollPosition = GUILayout.BeginScrollView(m_scrollPosition, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.box, GUILayout.Height(270)); if (!selectDrive) { m_selectedDirectory = GUILayoutx.SelectionList(m_selectedDirectory, m_directoriesWithImages, DirectoryDoubleClickCallback); if (m_selectedDirectory > -1) { m_selectedFile = m_selectedNonMatchingDirectory = -1; } m_selectedNonMatchingDirectory = GUILayoutx.SelectionList(m_selectedNonMatchingDirectory, m_nonMatchingDirectoriesWithImages, NonMatchingDirectoryDoubleClickCallback); if (m_selectedNonMatchingDirectory > -1) { m_selectedDirectory = m_selectedFile = -1; } GUI.enabled = BrowserType == MusicBrowserType.File; m_selectedFile = GUILayoutx.SelectionList(m_selectedFile, m_filesWithImages, FileDoubleClickCallback); GUI.enabled = true; if (m_selectedFile > -1) { m_selectedDirectory = m_selectedNonMatchingDirectory = -1; } if (m_filePattern == null) { GUI.enabled = false; GUILayoutx.SelectionList(-1, m_nonMatchingFilesWithImages); GUI.enabled = true; } } else { selectedDrive = GUILayoutx.SelectionList(selectedDrive, drivesContent, DrivesDoubleClickCallback); if (selectedDrive >= 0) { m_selectedFile = m_selectedNonMatchingDirectory = -1; } } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(150))) { m_callback(""); } if (BrowserType == MusicBrowserType.File) { GUI.enabled = m_selectedFile > -1; } else { if (m_filePattern == null) { GUI.enabled = m_selectedDirectory > -1; } else { GUI.enabled = m_selectedDirectory > -1 || (m_currentDirectoryMatches && m_selectedNonMatchingDirectory == -1 && m_selectedFile == -1); } } if (GUILayout.Button("Select", GUILayout.Width(150))) { if (BrowserType == MusicBrowserType.File) { SaveLastD(CurrentDirectory); m_callback(Path.Combine(m_currentDirectory, m_files[m_selectedFile])); } else { if (m_selectedDirectory > -1) { SaveLastD(CurrentDirectory); m_callback(Path.Combine(m_currentDirectory, m_directories[m_selectedDirectory])); } else { SaveLastD(CurrentDirectory); m_callback(m_currentDirectory); } } } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.EndArea(); if (Event.current.type == EventType.Repaint) { SwitchDirectoryNow(); } }
void DrawSaveLoadGUI(int WindowID) { if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer || Application.platform == RuntimePlatform.NaCl) { GUI.Label(new Rect(10, 20, 500, 80), "Please download the desktop application to save and/or load. Save & load will, hopefully, be available later in the webplayer."); } else if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor) { if (_simpleSaveLoadMode) { if (_simpleSelectingFileToLoad == false) { _saveDirectoryPath = Directory.GetCurrentDirectory() + "\\Maps"; //Name and description stuff GUI.Label(new Rect(10, 15, 350, 20), "Name:"); _saveName = GUI.TextArea(new Rect(10, 35, 350, 20), _saveName, 50); GUI.Label(new Rect(10, 55, 350, 20), "Description:"); _saveDescription = GUI.TextArea(new Rect(10, 75, 350, 60), _saveDescription, 150); if (GUI.Button(new Rect(10, 145, 170, 30), "Save!")) { SaveMap(); } if (GUI.Button(new Rect(190, 145, 170, 30), "Load!")) { string mapFolderPath = Directory.GetCurrentDirectory() + "\\Maps"; Directory.CreateDirectory(mapFolderPath); _simpleLoadFilesArray = Directory.GetFiles(mapFolderPath, "*." + LevelFileExtension); for (int i = 0, l = _simpleLoadFilesArray.Length; i < l; ++i) { int lastIndexOf = _simpleLoadFilesArray[i].LastIndexOf("\\"); _simpleLoadFilesArray[i] = _simpleLoadFilesArray[i].Remove(0, lastIndexOf + 1); lastIndexOf = _simpleLoadFilesArray[i].LastIndexOf("."); _simpleLoadFilesArray[i] = _simpleLoadFilesArray[i].Remove(lastIndexOf); } _simpleSelectingFileToLoad = true; } } else { GUI.Label(new Rect(10, 15, 350, 20), "Select Map to Load:"); if (_simpleLoadFilesArray.Length == 0) { GUI.Label(new Rect(10, 35, 350, 20), "No Maps Found :("); if (GUI.Button(new Rect(10, 55, 350, 30), "Ok")) { _simpleSelectingFileToLoad = false; } } else { _simpleLoadScrollPosition = GUI.BeginScrollView(new Rect(10, 35, 350, 190), _simpleLoadScrollPosition, new Rect(0, 0, 320, _simpleLoadFilesArray.Length * 20 + 40)); _simpleLoadFileID = GUILayoutx.SelectionList(_simpleLoadFileID, _simpleLoadFilesArray, SimpleLoadMap); GUI.EndScrollView(); } } } else { //Name and description stuff GUI.Label(new Rect(10, 15, 350, 20), "Name:"); _saveName = GUI.TextArea(new Rect(10, 35, 350, 20), _saveName, 50); GUI.Label(new Rect(10, 55, 350, 20), "Description:"); _saveDescription = GUI.TextArea(new Rect(10, 75, 350, 60), _saveDescription, 150); if (_saveDirectoryBrowser == null && _loadFileBrowser == null) { _saveLoadWindowRect.width = _nonBrowsingSize.width; _saveLoadWindowRect.height = _nonBrowsingSize.height; //SAVE if (GUI.Button(new Rect(10, 145, 290, 30), _saveDirectoryPath == null ? "Select Save Directory..." : _saveDirectoryPath )) { _saveDirectoryBrowser = new FileBrowser("Select Save Directory", SaveDirectorySelected); _saveDirectoryBrowser.BrowserType = FileBrowserType.Directory; } if (GUI.Button(new Rect(310, 145, 50, 30), "Save!")) { SaveMap(); } //LOAD if (GUI.Button(new Rect(10, 185, 290, 30), _loadFilePath == null ? "Select File to Load..." : _loadFilePath )) { _loadFileBrowser = new FileBrowser("Select File To Load", LoadFileSelected); _loadFileBrowser.BrowserType = FileBrowserType.File; _loadFileBrowser.SelectionPattern = "*." + LevelFileExtension; } if (GUI.Button(new Rect(310, 185, 50, 30), "Load!")) { LoadMap(); } } else { _saveLoadWindowRect.width = _browsingSize.width; _saveLoadWindowRect.height = _browsingSize.height; if (_saveDirectoryBrowser != null) { DrawSaveGUI(); } else { _loadFileBrowser.OnGUI(); } } } } else { GUI.Label(new Rect(10, 20, 200, 50), "Please download the desktop application to save and/or load."); } DrawGUIWindowCloseButton(ref _drawSaveLoadWindow); GUI.DragWindow(new Rect(0, 0, 10000, 20)); }
protected void OnGUI() { GUI.skin = skinWithListStyle; currentSelection = GUILayoutx.SelectionList(currentSelection, myList, DoubleClickItem); }
public void OnGUI() { GUI.enabled = true; GUILayout.BeginArea(m_screenRect, m_name, GUI.skin.window); GUILayout.BeginHorizontal(); if (m_currentDirectoryParts.Length == 0) // special case: drive selection { GUILayout.Label("PC", CentredText); } else { if (Directory.GetLogicalDrives().Length > 1) // go to drive selection if possible { if (GUILayout.Button("PC")) { SetNewDirectory(string.Empty); } } for (int parentIndex = 0; parentIndex < m_currentDirectoryParts.Length; ++parentIndex) { if (parentIndex == m_currentDirectoryParts.Length - 1) { GUILayout.Label(m_currentDirectoryParts[parentIndex], CentredText); } else if (GUILayout.Button(m_currentDirectoryParts[parentIndex])) { string parentDirectoryName = m_currentDirectory; for (int i = m_currentDirectoryParts.Length - 1; i > parentIndex; --i) { parentDirectoryName = Path.GetDirectoryName(parentDirectoryName); } SetNewDirectory(parentDirectoryName); } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.box ); m_selectedDirectory = GUILayoutx.SelectionList( m_selectedDirectory, m_directoriesWithImages, DirectoryDoubleClickCallback ); if (m_selectedDirectory > -1) { m_selectedFile = m_selectedNonMatchingDirectory = -1; } m_selectedNonMatchingDirectory = GUILayoutx.SelectionList( m_selectedNonMatchingDirectory, m_nonMatchingDirectoriesWithImages, NonMatchingDirectoryDoubleClickCallback ); if (m_selectedNonMatchingDirectory > -1) { m_selectedDirectory = m_selectedFile = -1; } GUI.enabled = BrowserType == FileBrowserType.File; m_selectedFile = GUILayoutx.SelectionList( m_selectedFile, m_filesWithImages, FileDoubleClickCallback ); GUI.enabled = true; if (m_selectedFile > -1) { m_selectedDirectory = m_selectedNonMatchingDirectory = -1; } GUI.enabled = false; GUILayoutx.SelectionList( -1, m_nonMatchingFilesWithImages ); GUI.enabled = true; GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(50))) { m_callback(null); } if (BrowserType == FileBrowserType.File) { GUI.enabled = m_selectedFile > -1; } else { if (SelectionPattern == null) { GUI.enabled = m_selectedDirectory > -1; } else { GUI.enabled = m_selectedDirectory > -1 || ( m_currentDirectoryMatches && m_selectedNonMatchingDirectory == -1 && m_selectedFile == -1 ); } } if (GUILayout.Button("Select", GUILayout.Width(50))) { if (BrowserType == FileBrowserType.File) { m_callback(Path.Combine(m_currentDirectory, m_files[m_selectedFile])); } else { if (m_selectedDirectory > -1) { m_callback(Path.Combine(m_currentDirectory, m_directories[m_selectedDirectory])); } else { m_callback(m_currentDirectory); } } } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.EndArea(); if (Event.current.type == EventType.Repaint) { SwitchDirectoryNow(); } }