I've been triyng to run the next script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextSlider : MonoBehaviour
{
//Objetos
public GameObject[] texts;
//Datos
public DatLoaders[] dats;
public float speed;
public int phase;
public int lvl;
float y;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
y = dats[phase].floater;
print(dats[phase].floater);
if (phase >= texts.Length)
{
FindObjectOfType().CHANGELEVE(lvl++);
}
if (phase <= texts.Length - 1)
{
for (int x = 0; texts[phase].transform.position.y < y;)
{
texts[x].GetComponent().anchoredPosition = new Vector3(0, texts[x].GetComponent().localPosition.y + speed * Time.deltaTime, 0);
x = x++;
x = Mathf.RoundToInt(Mathf.Repeat(x, phase + 1));
}
}
}
}
When trying to run it Unity just freezes, yet runs the code till the conditions to stop running it are acomplished, then it just show the results.
To be more specific, Unity freezes anytime it has to run the line 37 of the code:
for (int x = 0; texts[phase].transform.position.y < y;)
It is supossed to move image x up till it as high as Y. Unity doesn't show's it going up yet if it is possible it will unfreeze and show the image at the position.y where it should be. If it is not possible then Unity will remain freezed till its forcefully closed.
Example A: if the lines that make the image go up are deleted, therefore unabling to being above Y, Unity will freeze till closed.
Examble B: if the lines that make the image go are there, then Unity will freeze till enought time has passed for the image to be aboye Y, therefore displaying it as it just popped up there.
↧