Author Topic: UIDragDropItem.cs 169 line problem  (Read 3290 times)

leegod

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
UIDragDropItem.cs 169 line problem
« 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?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragDropItem.cs 169 line problem
« Reply #1 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?

leegod

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: UIDragDropItem.cs 169 line problem
« Reply #2 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!