Author Topic: problem resetting the cliprange in UIPanel. Please Help !  (Read 3235 times)

vinamra0202

  • Guest
problem resetting the cliprange in UIPanel. Please Help !
« on: June 21, 2013, 04:45:29 AM »
Hi,

I have searched a lot but could not solve this. Please help me out with this.

I am trying to position the UIDragPanel in and out of the scene on the click of a button. It is working perfectly fine if i don't move the items in the panel. If i am moving the items in the drag panel and then again clicking to move the UIDragPanel back and fro the position changes.

After searching a lot i found if i reset the clipping center x back to 0 it is working fine. Tried doing in inspector and it worked.

This code i am attaching with the button

        public UIPanel _DemGemSlider;

   private bool isClicked = false;

void OnClick()
   {
      
      isClicked = !isClicked;
      
      if(isClicked)
      {
                        // to bring the UIDragPanel in front of the camera
         TweenPosition.Begin(_DemGemSlider.gameObject, 0.1f, new Vector3(180, -29, -50));
      }
      if(!isClicked)
      {
                        //to push back the UIDragPanel out of the scene
         TweenPosition.Begin(_DemGemSlider.gameObject, 0.1f, new Vector3(1042, -29, -50));
                        //Reseting the cliprange to 0;
         Vector4 reset = _DemGemSlider.clipRange;
         reset.x = 0;
         reset.y = 0;
         _DemGemSlider.clipRange = reset;         
      }
   }

The value of x is not changing.

Also if i use prefabs for the same thing what will be effect and which approach is better?

Please help me out with this !!!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: problem resetting the cliprange in UIPanel. Please Help !
« Reply #1 on: June 21, 2013, 05:25:07 AM »
I'm not entirely clear on what it is you're trying to do. Why are you moving things inside a clipped panel? Why are you resetting the clip range? Clip panels are meant to work with fixed size content. You can make them work with flexible size content, but you need to notify the panel when the content dimensions change. Look at what the Quest Log example does.

vinamra0202

  • Guest
Re: problem resetting the cliprange in UIPanel. Please Help !
« Reply #2 on: June 21, 2013, 06:01:06 AM »
My Bad. I should have put it in a much refined form.

I have made a object which contains a draggable panel. On click of a button i am pulling this object so that it become visible. I am using TweenPosition to do this. When the user click on the button again this panel will go back to its original position i.e out of the scene so that another object can come into the picture.

This is working fine. On click the entire object with the draggable panel and items is changing position.

But, when the panel is visible and the items in the dragpanel are dragged the x of center clipping changes and after selecting an item if i click on the button again to push back the object it goes off but the value of x gets change. so if i call it again on click it positions itself at a different position.



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: problem resetting the cliprange in UIPanel. Please Help !
« Reply #3 on: June 21, 2013, 10:09:44 AM »
Remove UIButtonOffset from your buttons.