Esempio n. 1
0
    void findPathsRecursively(string path, ref List <ItemDatabase.ItemPath> PathList)
    {
        string[] directories = Directory.GetFileSystemEntries(path);

        foreach (string dirPath in directories)
        {
            if (dirPath.Contains(".prefab") && !dirPath.Contains(".meta")) //if Directory Path is a prefab
            {
                string localpath = dirPath;
                int    index     = localpath.IndexOf("/Resources");
                localpath = localpath.Remove(0, index + 11);

                int prefIndex = localpath.IndexOf(".prefab");
                localpath = localpath.Remove(prefIndex, localpath.Length - prefIndex);

                GameObject Loaded = Resources.Load(localpath) as GameObject;

                ItemBase itembs = Loaded.GetComponent <ItemBase>();
                if (itembs != null)
                {
                    ItemDatabase.ItemPath pc = new ItemDatabase.ItemPath();
                    pc.itemIdentifier = itembs.GetIdentifier();
                    pc.resourcesPath  = localpath;
                    PathList.Add(pc);
                    items.Add(new DisplayHolder(pc.itemIdentifier, itembs));
                }
                else
                {
                    Debug.LogError("ISWACK " + localpath);
                }
            }
            else if (!dirPath.Contains(".")) //If path is a folder
            {
                findPathsRecursively(dirPath, ref PathList);
            }
            else
            {
                //Literally do nothing
            }
        }
    }