Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Dustin_00

Pages: [1]
1
NGUI 3 Support / Re: Which UIButton did the Click come from?
« on: March 12, 2014, 11:07:20 PM »
This works right out of the gate:
  1.                 GameObject go = UICamera.hoveredObject;
  2.  

Which allowed me to clear out the UIButtonMessage components, and then figure out that to get the UIButton.current to work, I just needed to wire up that components OnClick event -- I was using something else (don't ask, I'm really new here).

Refactoring solves everything!

So thanks ArenMook, for the deprecation warning!

2
NGUI 3 Support / Re: Which UIButton did the Click come from?
« on: March 10, 2014, 11:47:33 PM »
My solution from Agent_007's hint:

I create a new script and add in the function:
  1.         public void SelectStartingShipPressed()
  2.         {
  3.                 HostScript.Instance.ButtonShipPressed(this.gameObject);
  4.         }
  5.  

HostScript is the script I actually want to call. Instance is the Singleton for it.
I select the GameObject in the Unity GUI that is the basis for shipButton.
On that I add the above script as a component
Then add UIButtonMessage Component and set the properties:
Target: the shipButton gameObject
Function Name: SelectStartingShipPressed
Trigger: OnClick

That does work. *phew*

ArenMook:
Now that you mention .current, I remember seeing that back in... December? Wow, that long ago? *sigh*

I tried adding into ButtonShipPressed():
  1. UIButton button = UIButton.current;
but button only got NULL assigned to it. As I have a working solution, my interest has faded in exploring further.

3
NGUI 3 Support / Which UIButton did the Click come from?
« on: March 10, 2014, 12:24:41 AM »
At run time I find out how many ships there are and Instantiate their buttons and they are all created with an event handler... but the event handler can't tell what button was clicked. Any suggestions?

  1. for (int n = 0; n < ship.Count; n++)
  2. {
  3.         GameObject o = Instantiate(shipButton) as GameObject;
  4.         UIButton button = o.GetComponent<UIButton>();
  5.         button.onClick.Add(new EventDelegate(this, "ButtonShipPressed"));
  6.  
  7.         UILabel label = o.GetComponentInChildren<UILabel>();
  8.         label.text = ship[n].Name;
  9.         // ...and other misc layout stuff...
  10. }
  11.  
  12. public void ButtonShipPressed()
  13. {
  14.         Debug.Log("Which one was clicked?");
  15.         }
  16.  

4
TNet 3 Support / Re: RFC function not recieving message
« on: February 01, 2014, 10:29:25 PM »
Yep, this fixes it:

  //GameObject container = new GameObject();
  GameObject container = GameObject.Find("Globals");

Wow... so simple... so deadly.

5
TNet 3 Support / Re: RFC function not recieving message
« on: February 01, 2014, 10:23:25 PM »
Ah! I think I see what I've done.

The actual Chat functions are in a singleton that the Global.HostScript is calling.

When the Singleton is created...
  GameObject container = new GameObject();
  container.name = "Chat";
  _Instance = (Chat)container.AddComponent(typeof(Chat));

So I am creating it dynamically at run time. Sounds like if I attach it to the HostScript's GameObject, I might be back on track...

6
TNet 3 Support / Re: RFC function not recieving message
« on: February 01, 2014, 09:23:04 PM »
Thank you for responding!

Some more details:
I have an empty root object called Globals. It has the TNManager, TNObject (Id = unique number, I've tried several now), and my custom script with the OnChat function.

I set a break point on the tno.Send() command and did "Step Into" and stepped all through the code... AND THAT WORKED!

So then I run without the break point... doesn't work.

Now I'm remembering why I dislike networking code.  ;)

7
TNet 3 Support / RFC function not recieving message
« on: February 01, 2014, 04:01:33 PM »
Been stuck here for a while. I can see all my comments as I step through getting into a group chat.
Initialize, Find Server, enter the server's Lobby, join channel, then:
tno.Send("OnChat", Target.All, TNManager.playerID, message);

But the
[RFC] void OnChat
never gets called.

Any suggestions on how to identify where my disconnect is?

Pages: [1]