Demigiant Forum
Unity Assets => DOTween & DOTween Pro => Topic started by: Brick 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:
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
-
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
-
Hi Daniele,
Thanks for the reply, i will give it a go and come back to you.
Cheers
Daniel
-
Hmm this is making no difference at all.
totally weird one..
Do you have any other suggestions?
Thanks
Daniel
-
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
-
just tried in with a new project and still wont work..
suggestions?
Thanks
-
Cant fix it.. using Unity animation system instead... too much time wasted on this bug.
Thanks