private List <Plot> Plots; // List of 'Plot' class objects for fast slide re-loading // Initialising the program void Start() { GameObject Camera = GameObject.FindGameObjectWithTag("MainCamera"); // Fetch the Camera object which is a child of the "Player" Object. NBodyPlotter = Camera.GetComponent <NBodyPlotter>(); // Assign the NBodyPlotter.cs script attached to the Camera object to variable name "NBodyPlotter" NBodyPlotter.enabled = false; // NBodyPlotter.cs should be disabled anyway but just in case... // Set the parameters from the inspector NBodyPlotter.m_numBodies = m_numBodies; NBodyPlotter.m_spacingScale = m_spacingScale; NBodyPlotter.m_zOffset = m_zOffset; NBodyPlotter.m_neighbourRadius = m_neighbourRadius; NBodyPlotter.m_defaultMass = m_defaultMass; Plots = new List <Plot>(0); // Initialise the list as empty DirectoryInfo dir = new DirectoryInfo(Application.streamingAssetsPath); // Obtain the Directory path of the StreamingAssets folder bundles with the game build ParticleData = dir.GetFiles("*.csv"); // Populate the FileInfo array with the files in the directory. NBodyPlotter.m_particleDataFile = ParticleData[currentFileIndex]; // Set the file to be loaded to the first one (currentFileIndex was initialised to 0) NBodyPlotter.SetPlots(Plots); // Set the variable 'Plots' in NBodyPlotter to the (empty) list held in this script. NBodyPlotter.enabled = true; // Launch the program! Plots = NBodyPlotter.ReturnPlots(); // Update the list of Plots with the loaded slide. }
// Public functions. These are called from Click.cs and SimpleXboxControllerInput.cs // Plot the next file and update the list of Plots. public void NextParticleData() { NBodyPlotter.enabled = false; // Disable the plotting script so it can be re-enabled where all the plotting happens if (currentFileIndex == ParticleData.Length - 1) { currentFileIndex = 0; } // Cycle the index else { currentFileIndex++; } // NBodyPlotter.m_particleDataFile = ParticleData[currentFileIndex]; // Use the index to retrieve and set the new file. NBodyPlotter.SetPlots(Plots); // Set the variable 'Plots' in NBodyPlotter to the (populated) list held in this script. NBodyPlotter.enabled = true; // Launch the program! Again! Plots = NBodyPlotter.ReturnPlots(); // Update the list of Plots. }