Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Bissmark 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
-
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.
-
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
-
I'm not sure how deleting an object is related to NGUI though?