//This returns a bool to prep for future failure possibilities, such as initialize/validation failure.
        public bool CreateRepresentations(string element)
        {
            //Debug.Log(s + "\n");
            LibraryElement libEle = fileContainer.AddPrefabToContainerReturn().GetComponent <LibraryElement>();

            //Elements need to be initialized so they get the proper name/icon/color
            libEle.Init(_assetTool, element, myNameSpace);

            return(true);
        }
        public void SetupLibraries()
        {
            //Base for the path - has ALL the folders
            string path = Application.streamingAssetsPath;

            //Find the folder with config.json
            List <string> folders = GetSubdirectoriesContainingOnlyFiles(path, "config.json").ToList();
            //This finds subfolders
            List <string> subFolders = GetSubdirectoriesContainingOnlyFiles(path, "config.json", SearchOption.AllDirectories).ToList();

            //Adds ones that are in subfolders
            for (int i = 0; i < subFolders.Count; i++)
            {
                //No double dipping
                if (!folders.Contains(subFolders[i]))
                {
                    folders.Add(subFolders[i]);
                }
            }

            //Debug.Log("We have found " + folders.Count + " subfolders\n\t\t" + path);
            for (int i = 0; i < folders.Count; i++)
            {
                //Debug.Log("Directory: " + folders[i] + "\n");

                //A library element represents either a folder or a haptic file. It will configure it's appearance based on its name (if it has .seq/.exp/.pat in its name, it'll adjust accordingly)
                LibraryElement libEle = FolderContainer.AddPrefabToContainerReturn().GetComponent <LibraryElement>();
                libEle.Init(folders[i]);
                libEle.playButton.transform.localScale = Vector3.one;
                libEle.playButton.name = folders[i];
                string folderName = folders[i];
                libEle.playButton.onClick.AddListener(
                    () => { SelectDirectory(folderName, libEle.playButton); }
                    );

                //Debug.Log(Selection == null);
                //string lastAccessed = LastOpened;

                //If we have something that we last accessed
                if (LastPackageAccessed.Length > 0 && folders.Contains(LastPackageAccessed))
                {
                    if (folderName == LastPackageAccessed)
                    {
                        SelectDirectory(folderName, libEle.playButton);
                    }
                }
                else if (folders.Count > 0)
                {
                    //Select the first folder
                    string first = folders[0];
                    SelectDirectory(first, libEle.playButton);
                }
            }
        }
        //This returns a bool to prep for future failure possibilities, such as initialize/validation failure.
        public bool CreateRepresentations(string element)
        {
            //Debug.Log(s + "\n");
            LibraryElement libEle = fileContainer.AddPrefabToContainerReturn().GetComponent <LibraryElement>();

            libEle.playButton.transform.localScale = Vector3.one;
            libEle.playButton.name = element;

            //Elements need to be initialized so they get the proper name/icon/color
            libEle.Init(element, myNameSpace);

            return(true);
        }
示例#4
0
        public void SetupLibraries()
        {
            //Base for the path - has ALL the folders
            string path = Application.streamingAssetsPath;

            assetTool.SetRootHapticsFolder(path + "/Haptics/");
            var packages = assetTool.TryGetPackageInfo();



            for (int i = 0; i < packages.Count; i++)
            {
                //Debug.Log("Directory: " + folders[i] + "\n");
                //A library element represents either a folder or a haptic file. It will configure it's appearance based on its name (if it has .seq/.exp/.pat in its name, it'll adjust accordingly)
                LibraryElement libEle = FolderContainer.AddPrefabToContainerReturn().GetComponent <LibraryElement>();
                libEle.Init(packages[i], assetTool);
                libEle.playButton.transform.localScale = Vector3.one;
                libEle.playButton.name = Path.GetFileName(packages[i].path);
                string folderName           = packages[i].path;
                AssetTool.PackageInfo tempP = packages[i];
                libEle.playButton.onClick.AddListener(
                    () => { SelectDirectory(tempP, libEle.playButton); }
                    );
                tempRef = libEle.gameObject;

                //Debug.Log(Selection == null);
                //string lastAccessed = LastOpened;

                //If we have something that we last accessed
                var found = packages.Find(item => item.path == LastPackageAccessed);
                if (LastPackageAccessed.Length > 0 && found != null)
                {
                    if (folderName == LastPackageAccessed)
                    {
                        SelectDirectory(packages[i], libEle.playButton);
                    }
                }
                else if (packages.Count > 0)
                {
                    //Select the first folder
                    SelectDirectory(packages[i], libEle.playButton);
                }
            }
        }