示例#1
0
        public void SetText(string s)
        {
            if (invalidCharsPath == null)
            {
                invalidCharsPath = SfbFileSystem.GetInvalidFileNameChars().ToList().Where(a => a != '/' && a != '\\').ToArray();
            }
            if (invalidCharsFileName == null)
            {
                // Remove control characters. This way the user is only notified about characters they can remove.
                invalidCharsFileName = SfbFileSystem.GetInvalidFileNameChars().ToList().Where(a => !char.IsControl(a)).ToArray();
            }
            if (inputField == null)
            {
                inputField = GetComponent <InputField>();
                inputField.onEndEdit.AddListener(OnSubmit);
            }
            if (fileBrowser == null)
            {
                fileBrowser = GetComponentInParent <SfbWindow>().fileBrowser;
            }

            text            = s;
            inputField.text = s;
            inputField.MoveTextEnd(true);
        }
        public override void Init(SfbInternal fileBrowser)
        {
            this.fileBrowser = fileBrowser;
            SetListeners();

            // Init because the start function won't be called until next frame if it's just been instantiated
            inputField.Init();
            var text = inputField.GetText();

            Stopwatch sw    = Stopwatch.StartNew();
            int       count = 1;

            while (fileBrowser.DirectoryExistsInCurrentDirectory(text))
            {
                if (sw.ElapsedMilliseconds > 500)
                {
                    text = inputField.GetText();
                    Debug.Log("Checking existing directories took too long, break.");
                    break;
                }

                text = inputField.GetText() + " (" + count + ")";
                count++;
            }

            inputField.SetText(text);
        }
示例#3
0
        public void Repopulate(IEnumerable<string> input)
        {
            if (type == SfbDropMenuType.NOT_SET) {
                Debug.LogError("DropMenu type not set.");
                return;
            }
            if (fileBrowser == null) {
                fileBrowser = GetComponentInParent<SfbWindow>().fileBrowser;
            }
            if (prefabItem == null || prefabItem.GetComponent<SfbDropMenuItem>() == null) {
                Debug.LogError("DropMenu item prefab not set or missing BrowserDropMenuItem component");
                return;
            }

            for (int i = 0; i < content.childCount; i++) {
                Destroy(content.GetChild(i).gameObject);
            }
            items.Clear();

            foreach (var item in input) {
                AddItem(item);
            }

            float height = items.Count() * prefabItem.GetComponent<RectTransform>().sizeDelta.y;
            if (height > maxHeight) {
                height = maxHeight;
            }
            else {

            }
            RectTransform rt = GetComponent<RectTransform>();
            rt.sizeDelta = new Vector2(rt.sizeDelta.x, height);
        }
示例#4
0
        public void Init(SfbInternal fileBrowser)
        {
            this.fileBrowser = fileBrowser;

            var children = GetComponentsInChildren<SfbIElement>();
            foreach (var child in children) {
                child.Init(fileBrowser);
            }
        }
示例#5
0
        public void SetListeners()
        {
            SfbInternal fileBrowser = GetComponentInParent <SfbWindow>().fileBrowser;

            if (fileBrowser == null)
            {
                return;
            }
            fileBrowser.SetButtonListeners(GetComponent <Button>(), action);
        }
示例#6
0
        public void Init(SfbInternal fileBrowser)
        {
            this.fileBrowser = fileBrowser;

            var children = GetComponentsInChildren <SfbIElement>();

            foreach (var child in children)
            {
                child.Init(fileBrowser);
            }
        }
示例#7
0
        public virtual void Init(SfbInternal fileBrowser)
        {
            this.fileBrowser = fileBrowser;
            clickStopwatch = Stopwatch.StartNew();

            scrollRect = GetComponentInChildren<ScrollRect>();
            parentDraggable = GetComponentInParent<SfbDraggable>();

            if (scrollRect.verticalScrollbar != null) {
                scrollRect.verticalScrollbar.onValueChanged.AddListener(StartShowOnScreenEntries);
            }
        }
        public override void Init(SfbInternal fileBrowser)
        {
            if (prefabFileEntry == null || prefabFolderEntry == null || prefabLogicalDriveEntry == null) {
                Debug.LogError("Prefabs not set correctly in inspector");
                return;
            }

            entryPrefabs.Add(prefabFileEntry);
            entryPrefabs.Add(prefabFolderEntry);
            entryPrefabs.Add(prefabLogicalDriveEntry);
            base.Init(fileBrowser);
        }
示例#9
0
        public override void Init(SfbInternal fileBrowser)
        {
            if (prefabFileEntry == null || prefabFolderEntry == null || prefabLogicalDriveEntry == null)
            {
                Debug.LogError("Prefabs not set correctly in inspector");
                return;
            }

            entryPrefabs.Add(prefabFileEntry);
            entryPrefabs.Add(prefabFolderEntry);
            entryPrefabs.Add(prefabLogicalDriveEntry);
            base.Init(fileBrowser);
        }
示例#10
0
        public virtual void Init(SfbInternal fileBrowser)
        {
            this.fileBrowser = fileBrowser;
            clickStopwatch   = Stopwatch.StartNew();

            scrollRect      = GetComponentInChildren <ScrollRect>();
            parentDraggable = GetComponentInParent <SfbDraggable>();

            if (scrollRect.verticalScrollbar != null)
            {
                scrollRect.verticalScrollbar.onValueChanged.AddListener(StartShowOnScreenEntries);
            }
        }
示例#11
0
        public void Repopulate(IEnumerable <string> input)
        {
            if (type == SfbDropMenuType.NOT_SET)
            {
                Debug.LogError("DropMenu type not set.");
                return;
            }
            if (fileBrowser == null)
            {
                fileBrowser = GetComponentInParent <SfbWindow>().fileBrowser;
            }
            if (prefabItem == null || prefabItem.GetComponent <SfbDropMenuItem>() == null)
            {
                Debug.LogError("DropMenu item prefab not set or missing BrowserDropMenuItem component");
                return;
            }

            for (int i = 0; i < content.childCount; i++)
            {
                Destroy(content.GetChild(i).gameObject);
            }
            items.Clear();

            foreach (var item in input)
            {
                AddItem(item);
            }

            float height = items.Count() * prefabItem.GetComponent <RectTransform>().sizeDelta.y;

            if (height > maxHeight)
            {
                height = maxHeight;
            }
            else
            {
            }
            RectTransform rt = GetComponent <RectTransform>();

            rt.sizeDelta = new Vector2(rt.sizeDelta.x, height);
        }
示例#12
0
        public void SetText(string s)
        {
            if (invalidCharsPath == null) {
                invalidCharsPath = SfbFileSystem.GetInvalidFileNameChars().ToList().Where(a => a != '/' && a != '\\').ToArray();
            }
            if (invalidCharsFileName == null) {
                // Remove control characters. This way the user is only notified about characters they can remove.
                invalidCharsFileName = SfbFileSystem.GetInvalidFileNameChars().ToList().Where(a => !char.IsControl(a)).ToArray();
            }
            if (inputField == null) {
                inputField = GetComponent<InputField>();
                inputField.onEndEdit.AddListener(OnSubmit);
            }
            if (fileBrowser == null) {
                fileBrowser = GetComponentInParent<SfbWindow>().fileBrowser;
            }

            text = s;
            inputField.text = s;
            inputField.MoveTextEnd(true);
        }
        public override void Init(SfbInternal fileBrowser)
        {
            this.fileBrowser = fileBrowser;
            SetListeners();

            // Init because the start function won't be called until next frame if it's just been instantiated
            inputField.Init();
            var text = inputField.GetText();

            Stopwatch sw = Stopwatch.StartNew();
            int count = 1;
            while (fileBrowser.DirectoryExistsInCurrentDirectory(text)) {
                if (sw.ElapsedMilliseconds > 500) {
                    text = inputField.GetText();
                    Debug.Log("Checking existing directories took too long, break.");
                    break;
                }

                text = inputField.GetText() + " (" + count + ")";
                count++;
            }

            inputField.SetText(text);
        }
示例#14
0
 public override void Init(SfbInternal fileBrowser)
 {
     this.fileBrowser = fileBrowser;
     SetListeners();
 }
示例#15
0
 public abstract void Init(SfbInternal fileBrowser);
 public bool SaveFile(string path, Action <string[]> outputMethod, string[] extensions = null)
 {
     return(SfbInternal.SaveFile(path, outputMethod, extensions));
 }
 private void Start()
 {
     fileBrowser = GetComponentInParent<SfbWindow>().fileBrowser;
 }
 public override void Init(SfbInternal fileBrowser)
 {
     this.fileBrowser = fileBrowser;
     SetListeners();
 }
 public void HideWindow()
 {
     SfbInternal.HideWindow();
 }
 private void Start()
 {
     fileBrowser = GetComponentInParent <SfbWindow>().fileBrowser;
 }
 public void ShowWindow()
 {
     SfbInternal.ShowWindow();
 }
示例#22
0
 public abstract void Init(SfbInternal fileBrowser);
 public void FakeFileSystem(SfbFileSystem fileSystem)
 {
     SfbInternal.FakeFileSystem(fileSystem);
 }
 public void SetParentCanvas(Canvas canvas)
 {
     SfbInternal.SetParentCanvas(canvas);
 }