Here's the problem. I set up a scoreboard, and made it so that my leantween would ease in some images (number of stars) on the scoreboard.
Here's the code that calls the void:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class ScoreBoard : MonoBehaviour
{
public float timerassesshigh; //change for every level (for gold)
public float timerassesslow; //change for every level (for silver)
public timer timer;
private SceneFadeEffect sceneFade;
private Scene scene;
public int nextLevelRecord;
private int levelcurrentat;
public string NextLevel;
public AudioSource leveldonedun;
private GameObject musicg;
public AudioSource music;
public Animator leveldonefade;
public Image leveldonefadesprite;
public GameObject buttons;
public rankaudioandlog rankaudioandlog;
private void Awake()
{
}
// Start is called before the first frame update
void Start()
{
scene = SceneManager.GetActiveScene();
levelcurrentat = PlayerPrefs.GetInt("levelreached");
sceneFade = FindObjectOfType<SceneFadeEffect>();
timer = FindObjectOfType<timer>();
leveldonefade.enabled = false;
leveldonefadesprite.enabled = false;
buttons.SetActive(false);
}
public void leveldone()
{
buttons.SetActive(true);
leveldonefadesprite.enabled = true;
leveldonefade.Rebind();
leveldonedun.Play();
music.Stop();
if (timerassesshigh >= timer.time)
{
rankaudioandlog.gotgold();
}
}
And here's the code that contains the leantween
public class rankaudioandlog : MonoBehaviour
{
public AudioSource bronze;
public AudioSource silver;
public AudioSource gold;
public GameObject goldobject;
public GameObject silverobject;
public GameObject bronzeobject;
public AudioSource leveldonecue;
private int levelnumberrank;
public string levelnumber;
public LeanTweenType InType;
private void Start()
{
levelnumberrank = PlayerPrefs.GetInt(("rankoflevel") + (levelnumber));
}
public void gotgold()
{
Debug.Log("You got gold!" + "on level" + levelnumber);
LeanTween.scale(bronzeobject, new Vector3(6.5f, 6.5f, 0f), 0.2f).setDelay(1.2f).setEase(InType);
bronze.PlayDelayed(2f);
LeanTween.scale(silverobject, new Vector3(6.5f, 6.5f, 0f), 0.2f).setDelay(2.2f).setEase(InType);
silver.PlayDelayed(3f);
LeanTween.scale(goldobject, new Vector3(6.5f, 6.5f, 0f), 0.2f).setDelay(3.2f).setEase(InType);
gold.PlayDelayed(4f);
cueendsong();
if (levelnumberrank == 3)
{
return;
}
else
{
Debug.Log("I logged gold");
PlayerPrefs.SetInt(("rankoflevel") + (levelnumber), 3);
}
}
}
Now, on another function, when the level ends and scoreboard is called, timescale becomes 0. That's why the leantween doesn't work. I need a workaround for that. Timescale has to stay 0, and leantween should start
Thanks ^^
OK, I figured it out!
I just had to add .setIgnoreTimeScale(true); to the tween.
Sorry for the trouble, and hopefully I helped someone too ^^.