Author Topic: TweenPosition Question/Issue  (Read 1547 times)

Bissmark

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
TweenPosition Question/Issue
« on: June 27, 2014, 04:55:58 AM »
Hi

I have a Button which when clicked actives a tween of a panel. The button also create an object which is a "preview model"
in the panel. So the panel tweens all well but I have to destroy the model which the panel tweens back into its start position and this seems to be causing issues.

public void ShowPreviewPanel()
   {
      TweenPosition pTweenTest;
      //Activates the preview panel. Also tweens the panel in and out
      if(previewPanel.active == false)
      {
         NGUITools.SetActive(previewPanel, true);
         pTweenTest = TweenPosition.Begin(previewPanel, 1f, new Vector3(-332,378,0));
      }
      else
      {
         pTweenTest = TweenPosition.Begin(previewPanel, 1f, new Vector3(-332,-200,0));
         EventDelegate.Add(pTweenTest.onFinished, OnFinishedPreview);
      }
   }

void OnFinishedPreview()
   {
      //Function call at the end of the tween to deactivate the panel and delete the preview object
      NGUITools.SetActive(previewPanel, false);
      Debug.Log ("Test");
      //NGUITools.Destroy(previewObject);
   }

So I think I want the Event being added to not be at end of the tween but actually at the beginning, so the model gets deleted and the tween happens but I am unsure of how to do this. I hope you can help, thank you

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition Question/Issue
« Reply #1 on: June 27, 2014, 01:36:36 PM »
I don't understand what you mean. You have to destroy the model which the panel tweens back? What? What issues are you experiencing? You never actually explained what's wrong.

Bissmark

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: TweenPosition Question/Issue
« Reply #2 on: June 27, 2014, 03:36:30 PM »
Oh my apologies
My issue is When the panel first gets tweened back the model is meant to be deleted so a new model can take its place. However sometimes the model gets deleted and sometimes it stays which causes issues because then on the next iteration the previous model is still there with a new model there aswell. This then causes both models to disappear when the preview panel gets tweened again.
I hope I have explained my issue alright

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition Question/Issue
« Reply #3 on: June 28, 2014, 04:34:18 PM »
I'm not sure how deleting an object is related to NGUI though?