Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: sawada on January 08, 2014, 01:04:43 PM

Title: OnDragDropRelease Error?
Post by: sawada on January 08, 2014, 01:04:43 PM
hi i am use Automatic translation,sorry

create splite and Attach Colider And Script,
this Script Extend [UIDragDropItem] and Use [OnDragDropRelease]


The [OnDragDropRelease] code is

protected override void OnDragDropRelease (GameObject surface)
{
if(surface.gameObject.name == this.gameObject.name){
   Debug.Log("why?");
}
Debug.Log("name " + surface.gameObject.name);
   }

In this state
drag splite,but may be Call "why" Log.

For example
drag at place without anything ,
drag at ather name ather splite,

This is what.  :'(

At what kind of time GameObject surface is Oneself splite

i use ngui [Version 3.0.8 f7]
Title: Re: OnDragDropRelease Error?
Post by: ArenMook on January 08, 2014, 01:12:04 PM
Happens when you don't disable the object's collider. The collider of the object you're dragging must be disabled when the dragging operation begins. Look inside UIDragDropItem.OnDragDropStart function:
  1.                 // Disable the collider so that it doesn't intercept events
  2.                 if (mCollider != null) mCollider.enabled = false;
I'm guessing you overrode that function and forgot to call that base.OnDragDropStart.
Title: Re: OnDragDropRelease Error?
Post by: sawada on January 09, 2014, 09:14:29 AM
thanks ArenMook,

I look OnDragDropStart,
And Write Under Code

  1.         protected virtual void OnDragDropStart ()
  2.         {
  3.                 // Automatically disable the scroll view
  4.                 if (mDragScrollView != null) mDragScrollView.enabled = false;
  5.                
  6.                 // Disable the collider so that it doesn't intercept events
  7.                 if (mCollider != null) mCollider.enabled = false;
  8.         }
  9.  

and

  1.         protected override void OnDragDropRelease (GameObject surface)
  2.         {      
  3.                 if (mCollider != null) mCollider.enabled = true;
  4.  
  5.                 if(surface.gameObject.name == this.gameObject.name){
  6.                         Debug.Log("why?");
  7.                 }
  8.                 Debug.Log("name " + surface.gameObject.name);
  9. }
  10.  

Start Test,
Drag Sprite so collider is don't disable,
Release Sprite collider is change disable,

but Drop othert splite so Call "why" Log :'(
this problem is not unresolved

I get advice agein?
Title: Re: OnDragDropRelease Error?
Post by: ArenMook on January 09, 2014, 06:50:28 PM
Then you need to investigate further. If the collider is disabled, then it should not be physically possible for it to receive events or get picked up by the UICamera. Yet it seems to get picked up. You'll need to investigate why it happens in your case.

As you can see this doesn't occur in the provided drag & drop example.

P.S. Also... why are you comparing names? You shouldn't compare names. Compare game objects.
Title: Re: OnDragDropRelease Error?
Post by: sawada on January 10, 2014, 08:30:14 AM
thanks ArenMook.
I will investigate more.
Reports Once you know what.

thanks a lot