- Home /
Tween move from CSV works on Editor but not on Android
I've been working on a script to update the position and rotation from a cube. The script gets the rotation and position values from a CVS script, i convert the CSV data to a Vector3 List.
With DOtween I move the cube with the pos and rot values. The cubes moves in my unity editor but not on my Oculus quest build.
I can log the result in windows and unity
Android log:
Unity log:
This is my script i use for the animations:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using DG.Tweening;
public class CSVAndroid: MonoBehaviour
{
public string motionFile = "WaveMotions.csv";
[Range (0.01f, 10f)]
public float updateAfterXseconds = 1.0f;
public List<Vector3> positionList = new List<Vector3>();
public List<Vector3> rotationList = new List<Vector3>();
public bool initialized = false;
public List<string> csvList;
public Text txt;
public Text txt2;
public bool _debugsOn = true;
[Header ("Object Movement")]
public Transform moveThisTransform;
public Ease easeType = Ease.Linear;
public bool localMovement = false;
public bool swapYZpos = false;
public bool loopData = true;
//Local Vars
private float secondTimer = 0f;
private int counter = 0;
private Vector3 goalPos = Vector3.zero;
private Vector3 goalRot = Vector3.zero;
void Awake()
{
csvList = new List<string> ();
StartCoroutine(ReadStream());
ParseCSVData();
}
void Update() {
secondTimer += Time.deltaTime;
if(secondTimer > updateAfterXseconds) {
secondTimer = 0f;
counter++;
StartTween();
}
}
public IEnumerator ReadStream()
{
string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, motionFile);
string result = "";
if (filePath.Contains("://"))
{
Debug.Log("Android_Log: Android Read Stream");
UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath);
yield return www.SendWebRequest();
result = www.downloadHandler.text;
txt2.text=result;
Debug.Log("Android_Log: Android_Result " + result);
}
else {
result = System.IO.File.ReadAllText(filePath);
txt.text=result;
Debug.Log("Android_Log: Windows_Result " + result);
}
using (TextReader reader = new StringReader(result))
{
string currentLine = reader.ReadLine ();
while (!string.IsNullOrEmpty (currentLine)) {
csvList.Add(currentLine);
currentLine = reader.ReadLine ();
}
}
}
public void ParseCSVData() {
Debug.Log("Android_Log: Running ParseCSVData");
for (int i = 1; i < csvList.Count; i++) {
string[] stringSplit = csvList [i].Split(new char[] { ',' }, System.StringSplitOptions.None);
if (!string.IsNullOrEmpty (stringSplit [0])) {
float id = float.Parse(stringSplit [0]);
float tempX = float.Parse(stringSplit [1]);
float tempY = 0f;
float tempZ = 0f;
if(!swapYZpos) {
tempY = float.Parse(stringSplit [2]);
tempZ = float.Parse(stringSplit [3]);
} else {
tempY = float.Parse(stringSplit [3]);
tempZ = float.Parse(stringSplit [2]);
}
Vector3 tempPos = new Vector3(tempX, tempY, tempZ);
float eulerX = float.Parse(stringSplit [4]);
float eulerY = float.Parse(stringSplit [5]);
float eulerZ = float.Parse(stringSplit [6]);
Vector3 tempRot = new Vector3(eulerX, eulerY, eulerZ);
positionList.Add(tempPos);
rotationList.Add(tempRot);
}
}
}
public void StartTween() {
if(counter < positionList.Count) {
goalPos = positionList[counter];
goalRot = rotationList[counter];
if(_debugsOn)
Debug.Log("Android_Log: Counter: <color=red>" + counter + "</color> Position: <color=orange>" + goalPos + "</color> Rotation: <color=green>" + goalRot + "</color>");
if(!localMovement) {
moveThisTransform.DOMove(goalPos, updateAfterXseconds).SetEase(easeType);
moveThisTransform.DORotate(goalRot, updateAfterXseconds).SetEase(easeType);
} else {
moveThisTransform.DOLocalMove(goalPos, updateAfterXseconds).SetEase(easeType);
moveThisTransform.DOLocalRotate(goalRot, updateAfterXseconds).SetEase(easeType);
}
} else {
counter = 0;
}
}
}
windows-log.png
(25.9 kB)
android-log.png
(51.7 kB)
Comment
Your answer
Follow this Question
Related Questions
[Crash] Unity with GearVR can crash after allowing permissions after first installation 1 Answer
Is there a way to get URP working with Oculus Integration? 1 Answer
Netcode not working on Quest 1 Answer
How to open a url in VR Browser from a Gear VR app? 1 Answer
Look and walk in VR unity 5.6.6 1 Answer