Author Topic: Draggable panel  (Read 7795 times)

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Draggable panel
« on: October 01, 2012, 09:50:40 AM »
Hey guys,

I am working on a level select system and I have most of it working. There is just one problem at this point. When I go back from my levelSelect menu of world 2 to my worldSelect menu the panel is back on world 1. What I would like is that when someone for example returns from world 2 to the worldSelect menu they are looking at the button to go to world 2 again.
I tried to get the localPosition of the panel and save that to a variable in a singleton object. so when I would return to the worldSelect menu I could take that value and assign that (in a start function on the panel) to the localPosition of the panel. This did not work unfortunately. What happened was that when I now enter world 2 and return, it slides back to the world 1 button. Then, when I slide back to the world 2 button, I am not able anymore to slide back to the world 1 button.
Is there someone that knows how to solve this problem.

Thanks in advance,
Max Uijlings

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable panel
« Reply #1 on: October 01, 2012, 05:00:25 PM »
Assuming its a draggable panel, saving the position isn't enough, you have to save the clipping rectangle as well.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Draggable panel
« Reply #2 on: October 02, 2012, 09:28:07 AM »
Oke so I managed to copy the clipping rectangle along with the local position. But now I run into the following problem. I set the local position and the clipping rectangle properties in a start function. But when I return from a lower level I do see that it starts at the right location but then it goes back to a location of 0,0,0 and the clipping rectangle also resets. Is there another place where these values are initialised and is there a way to suppress this?

Kind Regards,
Max Uijlings

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable panel
« Reply #3 on: October 02, 2012, 04:24:02 PM »
UIDraggablePanel also does its init in Start. Try doing yours in Awake instead.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Draggable panel
« Reply #4 on: October 02, 2012, 04:38:06 PM »
I tried that as well. What I found out is that it is the SpringPanel that is making this behaviour happen. But this is created during runtime and I am not quiet sure how to suppress this without breaking it. 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable panel
« Reply #5 on: October 02, 2012, 04:49:50 PM »
Try putting some Debug.Log statements and figure out where it's called from.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Draggable panel
« Reply #6 on: October 03, 2012, 11:31:49 AM »
I have tried to find out where this script is called from. But without any success. I did find out that without a UIDragablePanel it is not called. But when I go threw that script and comment out the place it looks it is called from it still is added to the panel and makes sure I cannot set the localPosition and clipping rectangle manually. Do you have any other suggestions?

Kind Regards,
Max Uylings

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable panel
« Reply #7 on: October 03, 2012, 07:43:33 PM »
Why no success? Put the Debug.Log statement in the tween's Awake function.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Draggable panel
« Reply #8 on: October 04, 2012, 06:05:17 AM »
Oke I have found out how to solve it.

I have put this code in my script where I also position the clipping rect and set the localPosition.
  1. function Awake(){
  2. GameObject.Find("Grid").GetComponent(UICenterOnChild).enabled= false;
  3. }
  4. function Start () {
  5. GameObject.Find("Grid").GetComponent(UICenterOnChild).enabled= true;
  6.  
  7. }

I do have to ask you why have you been so vague with me? You have to understand I am trying to run a commercial business here. Off course I am not asking you to solve my problems, but this was something that you clearly knew where I had to look. I was getting the feeling that I was debugging your program (which at this point I assume it is).
I am really happy with NGUI. Don't get me wrong, because I think it is a very useful tool and I will definitely keep using it and will recommend it to others. But please, I am not in high school anymore and I can't use these vague pointers about something that someone else wrote. Again, I am not asking you to write my code or solve my bugs. I am just asking to help me use your software in the best possible way. I imagine others can benefit from the way I solved this issue and how I use NGUI in my project.

Kind Regards,
Max Uijlings

 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable panel
« Reply #9 on: October 04, 2012, 10:17:20 AM »
You didn't post any code or screenshots of your UI set up. You described what you were doing in a project I have no access to. I'm not sure what else you were hoping I would do here. Offering "vague suggestions" is the best I can do. If I was sitting in front of your PC looking at your code, the first thing I would do is exactly what I suggested -- put in a bunch of Debug.Log statements in order to understand the call stack of events. Without the callstack how can I suggest how to properly address your issue?

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Draggable panel
« Reply #10 on: October 04, 2012, 11:07:44 AM »
Oke fair enough. that is a very good point I should have posted the code or made some screenshots. I thought I had supplied you with enough information that this was not necessary. Even though I still doubt that these vague suggestions were necessary especially because the script I was talking about is only called on two locations. But I also understand that this is probably something we are not going to agree about so lets agree to disagree. and I hope I can still ask you for advice in the future.

kind Regards,
Max Uijlings

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable panel
« Reply #11 on: October 04, 2012, 11:11:14 AM »
Of course, I try to help if I can.