public void Create(FileBrowseSpawner spawner, FileBrowseProp properties, string startingDir, string extensions, bool saving) { this.spawner = spawner; this.properties = properties; this.fileFilters = FileFilter.ParseFilterString(extensions); if (this.fileFilters.Length > 0) { this.filterIndex = 0; } this.saving = saving; if (System.IO.Directory.Exists(startingDir) == false) { // https://stackoverflow.com/questions/1143706/getting-the-path-of-the-home-directory-in-c startingDir = UnityEngine.Application.persistentDataPath; } //////////////////////////////////////////////////////////////////////////////// GameObject goCrumb = new GameObject("Crumb"); goCrumb.transform.SetParent(this.transform, false); FileBrowserCrumbRgn frCrumb = goCrumb.AddComponent <FileBrowserCrumbRgn>(); RectTransform rtCrumb = frCrumb.gameObject.AddComponent <RectTransform>(); rtCrumb.anchorMin = new Vector2(0.0f, 1.0f); rtCrumb.anchorMax = new Vector2(1.0f, 1.0f); rtCrumb.pivot = new Vector2(0.0f, 1.0f); rtCrumb.offsetMin = new Vector2(10.0f, -60.0f); rtCrumb.offsetMax = new Vector2(-10.0f, -10.0f); frCrumb.Create(properties, this); this.browserAreas.Add(frCrumb); //////////////////////////////////////////////////////////////////////////////// GameObject goFR = new GameObject("FilesRegion"); goFR.transform.SetParent(this.transform, false); FileBrowseFileListRgn frRgn = goFR.AddComponent <FileBrowseFileListRgn>(); RectTransform rtRgn = frRgn.gameObject.AddComponent <RectTransform>(); rtRgn.anchorMin = Vector2.zero; rtRgn.anchorMax = Vector2.one; rtRgn.pivot = new Vector2(0.0f, 1.0f); rtRgn.offsetMin = new Vector2(10.0f, 40.0f); rtRgn.offsetMax = new Vector2(-10.0f, -60.0f); frRgn.Create(properties, this); this.region = frRgn; this.browserAreas.Add(frRgn); //////////////////////////////////////////////////////////////////////////////// GameObject goPath = new GameObject("FilesPath"); goPath.transform.SetParent(this.transform, false); this.pathRgn = goPath.AddComponent <FileBrowserPathRgn>(); RectTransform rtPath = this.pathRgn.gameObject.AddComponent <RectTransform>(); rtPath.anchorMin = new Vector2(0.0f, 0.0f); rtPath.anchorMax = new Vector2(1.0f, 0.0f); rtPath.pivot = new Vector2(0.0f, 1.0f); rtPath.offsetMin = new Vector2(10.0f, 0.0f); rtPath.offsetMax = new Vector2(-10.0f, 40.0f); this.pathRgn.Create(properties, this); this.browserAreas.Add(this.pathRgn); //////////////////////////////////////////////////////////////////////////////// /// //GameObject goConfirm = new GameObject("Confirm"); //goConfirm.transform.SetParent(this.transform); //goConfirm.transform.localScale = Vector3.one; //goConfirm.transform.localRotation = Quaternion.identity; // //FileBrowserConfirmRgn confirmRgn = goConfirm.AddComponent<FileBrowserConfirmRgn>(); //RectTransform rtConf = confirmRgn.rectTransform; //rtConf.anchorMin = new Vector2(1.0f, 0.0f); //rtConf.anchorMax = new Vector2(1.0f, 0.0f); //rtConf.pivot = new Vector2(0.0f, 1.0f); //rtConf.offsetMin = new Vector2(-210.0f, 60.0f); //rtConf.offsetMax = new Vector2(-10.0f, 100.0f); // //confirmRgn.Create(this.properties, this); //this.browserAreas.Add(confirmRgn); this.ViewDirectory(startingDir, NavigationType.Misc); }
private void Awake() { spawner = this.GetComponent <FileBrowseSpawner>(); }