So, when i created an object with a script, the object only updates after i select on the play mode editor when it should automatically get initialized, here is the video showing the issue. i don’t know how it will affect the built app but i haven’t tested it yet on a device because i can’t really use AR on my device, still waiting for my friend to wake up hours later
z81tf3
and here’s the code, at CreateScatterplotVisualization method
using System.Collections;
using System.Collections.Generic;
using IATK;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ConfigListener : MonoBehaviour
{
public TMP_Dropdown dropdownX;
public TMP_Dropdown dropdownY;
public TMP_Dropdown dropdownZ;
// Start is called before the first frame update
void Start()
{
string csvPath = PlayerPrefs.GetString("FilePath");
CSVDataSource dataSource = new CSVDataSource();
dataSource.LoadFromFile(csvPath);
// Get the available dimensions
List<string> dimensions = new List<string>();
for (int i = 0; i < dataSource.DimensionCount; i++)
{
dimensions.Add(dataSource[i].Identifier);
}
// Populate the dropdown menus
dropdownX.ClearOptions();
dropdownX.AddOptions(dimensions);
dropdownY.ClearOptions();
dropdownY.AddOptions(dimensions);
dropdownZ.ClearOptions();
dropdownZ.AddOptions(dimensions);
}
// to load the next scene
public void LoadAR()
{
SceneManager.LoadScene("datavisual", LoadSceneMode.Single);
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
string xDimension = dropdownX.options[dropdownX.value].text;
string yDimension = dropdownY.options[dropdownY.value].text;
string zDimension = dropdownZ.options[dropdownZ.value].text;
if (scene.name == "datavisual")
{
CreateScatterplotVisualization(xDimension, yDimension, zDimension);
SceneManager.sceneLoaded -= OnSceneLoaded; // Unsubscribe from the event
}
}
private void CreateScatterplotVisualization(string xDimension, string yDimension, string zDimension)
{
// Find the Ground Plane Stage GameObject in the datavisual scene
GameObject groundPlaneStage = GameObject.Find("Ground Plane Stage");
if (groundPlaneStage != null)
{
// Create a new GameObject for the visualization
GameObject visualizationObject = new GameObject("ScatterplotVisualization");
visualizationObject.transform.SetParent(groundPlaneStage.transform);
// Add the Visualisation component to the new GameObject
Visualisation visualisation = visualizationObject.AddComponent<Visualisation>();
string csvPath = PlayerPrefs.GetString("FilePath");
CSVDataSource dataSource = visualizationObject.AddComponent<CSVDataSource>();
dataSource.LoadFromFile(csvPath);
// Configure the Visualisation component
// visualisation.visualisationType = AbstractVisualisation.VisualisationTypes.SCATTERPLOT;
visualisation.dataSource = dataSource;
visualisation.xDimension.Attribute = xDimension;
visualisation.yDimension.Attribute = yDimension;
visualisation.zDimension.Attribute = zDimension;
visualisation.geometry = AbstractVisualisation.GeometryType.Points;
visualisation.updateProperties();
visualisation.CreateVisualisation(AbstractVisualisation.VisualisationTypes.SCATTERPLOT);
}
else
{
Debug.LogError("Ground Plane Stage GameObject not found in the datavisual scene.");
}
}
// Update is called once per frame
void Update()
{
}
}