Author Topic: NGUI and TNet (Weird Issue)  (Read 3255 times)

droweed

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 16
    • View Profile
NGUI and TNet (Weird Issue)
« on: February 25, 2014, 04:41:22 AM »
Just purchased TNet cause our project currently requires it.

I created a quick start->connect->join channel->new scene->disconnect->stop server flow using ngui.
now the problem occurs not on first flow, but on the second round.

I'm using UIButton script for the buttons, and just add a notify on click, but it seems on the second round, the delegates are no longer there, its its just a blank on click..

I think I may be missing something very obvious here.. any help would be really appreciated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI and TNet (Weird Issue)
« Reply #1 on: February 25, 2014, 03:31:05 PM »
This sounds like an NGUI question rather than a TNet question. How are you adding the delegate?

droweed

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 16
    • View Profile
Re: NGUI and TNet (Weird Issue)
« Reply #2 on: February 25, 2014, 08:54:41 PM »
This sounds like an NGUI question rather than a TNet question. How are you adding the delegate?

Ahh sorry, I'll move this query to NGUI thread, but currently just using the editor drag and drop, on the onclick for the UIButton script.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI and TNet (Weird Issue)
« Reply #3 on: February 26, 2014, 04:02:22 PM »
If one object is persistent and another is not, references will get broken when you switch scenes.

droweed

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 16
    • View Profile
Re: NGUI and TNet (Weird Issue)
« Reply #4 on: February 26, 2014, 07:56:47 PM »
Yeah, I guess I'll just have to remove the UIButton script, and just let it handle OnClick() {} instead via another script attached on that button.

Just wanna ask would that be the best approach or, re-assign the delegates once the scene is loaded again.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI and TNet (Weird Issue)
« Reply #5 on: February 27, 2014, 06:58:40 PM »
I'd have the button have a script on it that did something rather than setting its delegate. As long as the script has the "void OnClick ()" function, it'll be called as expected.

droweed

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 16
    • View Profile
Re: NGUI and TNet (Weird Issue)
« Reply #6 on: February 27, 2014, 08:38:12 PM »
Yep thought so, thanks for the quick response.