Author Topic: UIButton's color in DraggablePanel problem  (Read 3940 times)

ZJB

  • Guest
UIButton's color in DraggablePanel problem
« on: July 10, 2012, 06:03:04 AM »
I have been using the UIButton in DraggablePanel, I am of OnPress would like to change the color, while dragging the panel OnPress is enabled, the color has changed, do not change the color while dragging but is there a way?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton's color in DraggablePanel problem
« Reply #1 on: July 10, 2012, 06:21:18 AM »
I read what you wrote 4 times and I still am not sure what you are asking. Just one long run-on sentence to me...

simon129

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 20
    • View Profile
Re: UIButton's color in DraggablePanel problem
« Reply #2 on: July 10, 2012, 09:27:40 PM »
I think ZJB has a UIButton on DraggablePanel, and using OnPress to change button's color, he doesn't want to change the color while dragging the button(panel).
« Last Edit: July 10, 2012, 09:29:36 PM by simon129 »

ZJB

  • Guest
Re: UIButton's color in DraggablePanel problem
« Reply #3 on: July 10, 2012, 11:24:53 PM »
>ArenMook
I'm sorry, I am Japanese, and English is weak

>simon129
Thank you, is exactly that, and then upload the image for description


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton's color in DraggablePanel problem
« Reply #4 on: July 10, 2012, 11:26:11 PM »
Remove the UIButton script from it, and it won't change colors.

ZJB

  • Guest
Re: UIButton's color in DraggablePanel problem
« Reply #5 on: July 11, 2012, 01:04:17 AM »
I can't Remove the UIButton script.
Because, while dragging I do not want to change the color,
but When a button is OnPress without dragging, I want change a color.
« Last Edit: July 11, 2012, 01:10:08 AM by ZJB »

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: UIButton's color in DraggablePanel problem
« Reply #6 on: July 11, 2012, 03:54:58 AM »
As long as you don't mind the button tweening colors on the mouseover, you could just modify your onDrag function to tween the button background back to the default color value.  Or, perhaps, during OnDrag you could disable the UIButton component of the gameobject... although that's something I've not tried yet, so no promises.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton's color in DraggablePanel problem
« Reply #7 on: July 11, 2012, 05:04:09 AM »
You can't have drag events without an OnPress event. The order is always:

OnPress(true)
OnDrag(delta) repeated many times as you drag
OnPress(false)

If you want something different, you will need to code the logic for it yourself.

simon129

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 20
    • View Profile
Re: UIButton's color in DraggablePanel problem
« Reply #8 on: July 11, 2012, 05:50:26 AM »
I have a situation like yours, here is how I do,

I try to mimic how UICamera.ProcessTouch(bool, bool) does on OnDrag and OnClick

  1. public UICamera mCam;
  2. void OnDrag(Vector2 delta)
  3. {
  4.     if (UICamera.currentTouch.totalDelta.magnitude > mCam.touchClickThreshold)
  5.     {
  6.         tween off
  7.     }
  8. }
  9.  
« Last Edit: July 11, 2012, 05:52:52 AM by simon129 »

ZJB

  • Guest
Re: UIButton's color in DraggablePanel problem
« Reply #9 on: July 11, 2012, 07:30:19 AM »
ArenMook, simon129, Thank you verymuch!!!
I try in the way.
And if it completes, it will report.

ZJB

  • Guest
Re: UIButton's color in DraggablePanel problem
« Reply #10 on: July 11, 2012, 11:01:13 PM »
Has succeeded in referring to the code of simon129, thank everyone, great!!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class DraggingNoneTween : MonoBehaviour
  5. {
  6.         public UICamera mCam;
  7.        
  8.         void OnDrag()
  9.         {
  10.                 if (UICamera.currentTouch.totalDelta.magnitude > mCam.touchClickThreshold)
  11.                         gameObject.transform.Find("Background").GetComponent<UISprite>().color = Color.white;
  12.         }
  13. }