public static void SpawnObject()
    {
        GameObject NewOBJ;

        List <string> AllFiles = new List <string>(Directory.GetFiles(Application.dataPath + "/prefabs/items/"));
        string        Path;

        foreach (string Thingy in AllFiles)
        {
            Path   = "Assets" + Thingy.Replace(Application.dataPath, "").Replace('\\', '/');
            NewOBJ = (GameObject)AssetDatabase.LoadAssetAtPath(Path, typeof(GameObject));
            PrefabUtility.InstantiatePrefab(NewOBJ);
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// Checks to see how many files are found from the sacn so it can be displayed.
        /// </summary>
        /// <returns></returns>
        private int CheckAmount()
        {
            int           _amount   = 0;
            List <string> _allFiles = new List <string>();

            for (int i = 0; i < audioManagerScript.audioManagerFile.directory.Count; i++)
            {
                if (AreAllDirctoryStringsBlank())
                {
                    _allFiles = new List <string>(Directory.GetFiles(Application.dataPath + "/audio"));
                }
                else
                {
                    if (Directory.Exists(Application.dataPath + "/audio/" + audioManagerScript.audioManagerFile.directory[i]))
                    {
                        // 2.3.1 - adds a range so it adds each directory to the asset 1 by 1
                        _allFiles.AddRange(new List <string>(Directory.GetFiles(Application.dataPath + "/audio/" + audioManagerScript.audioManagerFile.directory[i])));
                    }
                    else
                    {
                        // !Warning Message - shown in the console should there not be a directory named what the user entered
                        _allFiles         = new List <string>();
                        shouldShowMessage = true;
                    }
                }
            }

            // Checks to see if there is anything in the path, if its empty it will not run the rest of the code and instead put a message in the console
            if (_allFiles.Count > 0)
            {
                foreach (string Thingy in _allFiles)
                {
                    string _path = "Assets" + Thingy.Replace(Application.dataPath, "").Replace('\\', '/');

                    if (AssetDatabase.LoadAssetAtPath(_path, typeof(AudioClip)))
                    {
                        ++_amount;
                    }
                }
            }

            return(_amount);
        }