*

Brick

  • ***
  • 25
    • View Profile
DoTween doesnt work correctly on Android
« on: October 21, 2015, 11:43:15 AM »
Hi This well could be User error, but it all works perfect in unity but not on a device.
This is the code:
Code: [Select]
using UnityEngine;
using System.Collections;
using DG.Tweening;
using UnityEngine.UI;

public class MoveMenu : MonoBehaviour
{
    public GameObject go;
   public Transform tran;
   public Button btnOut;
   public Button btnIn;
   public bool moveBool = false;
   private float objectSize;
    // Use this for initialization
void Start ()
{
    objectSize = (float)go.GetComponent<Renderer>().bounds.size.x;
}

// Update is called once per frame
void Update () {
 
}

    public void moveIt()
    {
        if (!moveBool)
        {
           tran.DOMoveX(Screen.width + objectSize  , .5f).SetRelative();
           moveBool = true;
           btnOut.gameObject.SetActive(false);
           btnIn.gameObject.SetActive(true);
        }
        else
        {
           tran.DOMoveX(-Screen.width + objectSize, .5f).SetRelative();
           moveBool = false;
           btnOut.gameObject.SetActive(true);
           btnIn.gameObject.SetActive(false);
        }
    }
}

What happens is the menu shoots to center as it should but will not go back again.. literally goes back a tiny amount at a time.

Not sure why but works perfect on PC but not android..

Thanks

Daniel
« Last Edit: October 25, 2015, 10:11:40 PM by Daniele »

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DoTween doesnt work correctly on Android
« Reply #1 on: October 25, 2015, 10:17:20 PM »
Hi,

I'm pretty sure there's no difference in DOTween's functionality between PC and Android, so there must be something else going on. The thing that come to my mind is that you might have the previous "tween to center" still running when you create the "tween out" one, and thus they end up running concurrently. Call tran.DOKill() to kill any tween on that same transform before creating a new one. This might happen on Android but not on PC simply because Unity orders stuff differently there, and thus the second tween takes the precedence on PC while the first one takes precedence on Android (but it's completely random, so this could happen on PC too).

Cheers,
Daniele

*

Brick

  • ***
  • 25
    • View Profile
Re: DoTween doesnt work correctly on Android
« Reply #2 on: October 25, 2015, 10:26:12 PM »
Hi Daniele,

Thanks for the reply, i will give it a go and come back to you.

Cheers

Daniel

*

Brick

  • ***
  • 25
    • View Profile
Re: DoTween doesnt work correctly on Android
« Reply #3 on: October 26, 2015, 04:21:20 PM »
Hmm this is making no difference at all.

totally weird one..

Do you have any other suggestions?

Thanks

Daniel

*

Brick

  • ***
  • 25
    • View Profile
Re: DoTween doesnt work correctly on Android
« Reply #4 on: October 26, 2015, 04:47:52 PM »
Ok i have tried several different approaches to try and figure this out still cant get it to work..

I have created a separate transform to handle the return but this didnt work , so i then created a separate script to hold the Screen Width to make sure it wasn't getting confused by some means and this also didnt work..

really not sure whats going down to be honest..

Suggestions welcome..

Thanks

Daniel

*

Brick

  • ***
  • 25
    • View Profile
Re: DoTween doesnt work correctly on Android
« Reply #5 on: October 26, 2015, 06:03:06 PM »
just tried in with a new project and still wont work..

suggestions?

Thanks

*

Brick

  • ***
  • 25
    • View Profile
Re: DoTween doesnt work correctly on Android
« Reply #6 on: October 30, 2015, 02:52:35 PM »
Cant fix it.. using Unity animation system instead... too much time wasted on this bug.

Thanks