Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to stop/cancel leantween?

Discussion in 'Scripting' started by eziovain, May 15, 2022.

  1. eziovain

    eziovain

    Joined:
    Mar 1, 2021
    Posts:
    2
    Code (CSharp):
    1.  
    2. IEnumerator StartSpawn()
    3.     {
    4.         if(coroutineEnabled){
    5.             index = Random.Range(0, articals.Count);
    6.             GameObject _temp = Instantiate(articals[index],gameObject.transform.position, Quaternion.identity) as GameObject;
    7.             _temp.transform.SetParent(transform,true);
    8.             _temp.transform.localScale = Vector2.one;
    9.             _temp.transform.localPosition = new Vector2(Screen.width,transform.localPosition.y);
    10.             _temp.LeanMoveLocalX(-Screen.width, 15f).setOnComplete(DestroyGameObject);
    11.             yield return new WaitForSeconds(waitTime);
    12.             StartCoroutine(StartSpawn());
    13.         }
    14.     }
     
  2. eziovain

    eziovain

    Joined:
    Mar 1, 2021
    Posts:
    2
    I have a coroutine that spawn a gameObject and moves it across the screen with LeanTween. but at an event i want to stop all the gameObjects at their positions.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,963
    Google tells me there's a
    cancel
    and a
    reset
    , plus you likely can just Destroy() the tween, leaving the object alone.
     
    cesarcaos likes this.
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,150