Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: leegod on September 16, 2014, 04:26:18 AM

Title: UIDragDropItem.cs 169 line problem
Post by: leegod on September 16, 2014, 04:26:18 AM
So I made custom script like this,

  1. public class NguiDragRevise : UIDragDropItem {
  2.         public UIScrollView myscroll;
  3.  
  4.         void Start(){
  5.                 myscroll = GameObject.Find("AllyScroll").GetComponent<UIScrollView>();
  6.         }
  7.         protected override void OnDragDropRelease(GameObject obj)
  8.         {
  9.                 myscroll.RestrictWithinBounds(false);
  10.                 base.OnDragDropRelease(obj);
  11.         }
  12. }
  13.  

For solve my last post's dragging problem.

When I attach this script instead of UIDragDropItem script, and if I try to move this item out, error says,

------------
NullReferenceException: Object reference not set to an instance of an object
UIDragDropItem.OnDrag (Vector2 delta) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:169)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:1052)
UICamera:ProcessTouch(Boolean, Boolean) (at Assets/NGUI/Scripts/UI/UICamera.cs:1721)
UICamera:ProcessMouse() (at Assets/NGUI/Scripts/UI/UICamera.cs:1388)
UICamera:ProcessTouches() (at Assets/NGUI/Scripts/UI/UICamera.cs:1460)
UICamera:Update() (at Assets/NGUI/Scripts/UI/UICamera.cs:1207)
-----------

What is problem, how solve?

Title: Re: UIDragDropItem.cs 169 line problem
Post by: ArenMook on September 16, 2014, 09:52:11 AM
Do you not see that warning in the console log that tells you that you defined a new Start() function instead of overwriting the one in the parent class?
Title: Re: UIDragDropItem.cs 169 line problem
Post by: leegod on September 16, 2014, 08:09:30 PM
Do you not see that warning in the console log that tells you that you defined a new Start() function instead of overwriting the one in the parent class?

Thx, I removed my Start function and it works!