Esempio n. 1
0
 private void Awake()
 {
     savePath = true;
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
     // Persist this object. Destroy it if you want to reload the scene
     DontDestroyOnLoad(this);
     path        = null;
     guiBehavior = FindObjectOfType <folderGUIBehavior>();
     pathSaver   = FindObjectOfType <pathSaveAndLoad>();
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        // Persist this object. Destroy it if you want to reload the scene
        DontDestroyOnLoad(this);
        isUnleashed        = false;
        currentLetterCount = 0;
        numFolders         = 0;
        GUIbehaviorScpt    = FindObjectOfType <folderGUIBehavior>();

        int    method     = 0;                           // Method used to load images. Web/ local files
        char   separator  = Path.DirectorySeparatorChar; // Different separators for unix/ windows file paths
        string pathToRoot = null;                        // the path to the root folder containing the images

        invalidPathDebug = GameObject.Find("invalidPath");
        invalidPathDebug.SetActive(false);

        // Check if a different path to the images other than resources was specified
        customPath = pathToRoot = FindObjectOfType <pathBasedLoader>().path;
        if ((customPath != null) && (customPath != ""))
        {
            // If the path was invalid, set the custom path to null
            if (!Directory.Exists(pathToRoot))
            {
                customPath = FindObjectOfType <pathBasedLoader>().path = null; // Reset the path variable
                invalidPathDebug.SetActive(true);                              // Activate the invalid path debug text
            }
        }
        // If our custom path is null,
        if (customPath == null)
        {
            // Hard code Image folder location as default.
            pathToRoot = Application.dataPath + separator + "ImageFolder";
        }
        string[] items = pathToRoot.Split(separator);
        rootFolder = items[items.Length - 1];
        // Load/ display type defaults to cylindrical load
        loadType          = 1;                                                                               // 0 - Spiral, 1 - cylinder
        folderTemplate    = Resources.Load <GameObject>("Prefabs" + separator + "FolderObject");             // Get the folder template prefab from resources
        directoryInquirer = FindObjectOfType <FileLoader>();                                                 // Load a fileLoader script to help get directory info

        DirectoryInfo[] directoryInfos = directoryInquirer.GetDirectoryInfo(method, rootFolder, customPath); // Get directory info for subfolders of ImageFolder

        DirectoryInfo rootFolderInfo = null;

        rootFolderInfo = new DirectoryInfo(pathToRoot);   // Get Directory info for rootFolder

        // Check if any of the queried directories contain any images.
        // If they do, add them to the scene (all happens in checkDirectoryAndAdd)
        checkDirectoryAndAdd(rootFolderInfo, true);
        foreach (DirectoryInfo dInfo in directoryInfos)
        {
            checkDirectoryAndAdd(dInfo);
        }
        // If we found no images, let the "No images" button stay
        if (numFolders == 0)
        {
            GUIbehaviorScpt.togglePathMenu(); //And turn on the path menu
            return;
        }
        // Otherwise
        GameObject.Find("noImages").SetActive(false);
        // Update the gui to enable scrolling if we have more than 7 rows
        if (numFolders - 14 > 0)
        {
            int maxoffset = Mathf.CeilToInt(((float)(numFolders - 14)) / 2);
            GUIbehaviorScpt.setMaxOffset(maxoffset);
        }
        //System.GC.Collect();
    }