Author Topic: OnDragOut() simulating what stickyPress used to do/  (Read 2850 times)

tora

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
OnDragOut() simulating what stickyPress used to do/
« on: January 14, 2015, 09:42:35 PM »
Hello, I am a noob at programming and never really used the stickyPress ability that NGUI had.
I am programming for touch devices with the latest versions of Unity and NGUI
My question is, How do i simulate what stickyPress use to do with OnDragOut() or force the release any button.

   #region NGUIFunction
   void OnPress (bool isPressed)
   {
      if(StaticVariables.isTheGamePaused == false)
      {
         if (isPressed)
         {   //if this is a jumping button
            if(jumpB)
            {   //tell the player to jump
               _pI.Jump ();
            }
            else if(magicB)
            {   //start the magic skill
               _pI.DoMagic ();
            }
            else if(shieldB)
            {   //start shield
               _pI.Shield(isPressed);
            }
         }
         else if(!isPressed && shieldB)
         {   //stop shield
            _pI.Shield(isPressed);
         }

      }
   }

   void OnDragOut()
   {   //Release this button
      //OnPress (false);
   }
   #endregion

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnDragOut() simulating what stickyPress used to do/
« Reply #1 on: January 15, 2015, 09:02:45 PM »
It's an option on the button... "Drag Over" field. UIButton simply adds two functions -- OnDragOver and OnDragOut with one line of code in each. Just check the source code.

tora

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: OnDragOut() simulating what stickyPress used to do/
« Reply #2 on: January 18, 2015, 03:48:44 AM »
Thank you, I did not see that. The solution was right in my face...  :-[