Skip to main content
added 885 characters in body
Source Link

I've added some text to a unity UI and set both the achor and pivot to the top right corner as shown here:

enter image description here

When I start this in debug in unity the text looks fine:

enter image description here

What's weird is that when I build the app and run it as an executable as a host (this is a multiplayer networked game) the text also looks fine. But when I start a client instance the text doesn't appear.

I debugged and paused the game in unity in client mode and noticed that the text object is miles away from where I'm expecting it to be (and as a result doesn't show on the camera).

You can just about see the black line on the below image which is my level and the text anchored miles up and right of the level.

It seems like I've done something stupid here but I can't work out what :s

enter image description here

EDIT: Leo's answer was correct conceptually, but here's how I implemented the suggestion.

  1. Created an empty game object GameStateManager in the hierarchy
  2. Add a GameState script to the manager with a network identity
  3. Added my 'RemainingTime' property to the game state script and put the [SyncVar] attribute on it
  4. Put logic in the game state Update method to update the remaining time
  5. Added a ClientTimer script to the text object (mono behaviour), which retrieved the GameState from within the clients copy of the game state manager.
  6. In the update method of the client time, get a reference to the Text object and set the .text property to the value of the remaining time.

I'm not sure if this is correct, but it does seem to work, and now the ClientTimer script isn't networked, which resolved the issues with placement of the text.

I've added some text to a unity UI and set both the achor and pivot to the top right corner as shown here:

enter image description here

When I start this in debug in unity the text looks fine:

enter image description here

What's weird is that when I build the app and run it as an executable as a host (this is a multiplayer networked game) the text also looks fine. But when I start a client instance the text doesn't appear.

I debugged and paused the game in unity in client mode and noticed that the text object is miles away from where I'm expecting it to be (and as a result doesn't show on the camera).

You can just about see the black line on the below image which is my level and the text anchored miles up and right of the level.

It seems like I've done something stupid here but I can't work out what :s

enter image description here

I've added some text to a unity UI and set both the achor and pivot to the top right corner as shown here:

enter image description here

When I start this in debug in unity the text looks fine:

enter image description here

What's weird is that when I build the app and run it as an executable as a host (this is a multiplayer networked game) the text also looks fine. But when I start a client instance the text doesn't appear.

I debugged and paused the game in unity in client mode and noticed that the text object is miles away from where I'm expecting it to be (and as a result doesn't show on the camera).

You can just about see the black line on the below image which is my level and the text anchored miles up and right of the level.

It seems like I've done something stupid here but I can't work out what :s

enter image description here

EDIT: Leo's answer was correct conceptually, but here's how I implemented the suggestion.

  1. Created an empty game object GameStateManager in the hierarchy
  2. Add a GameState script to the manager with a network identity
  3. Added my 'RemainingTime' property to the game state script and put the [SyncVar] attribute on it
  4. Put logic in the game state Update method to update the remaining time
  5. Added a ClientTimer script to the text object (mono behaviour), which retrieved the GameState from within the clients copy of the game state manager.
  6. In the update method of the client time, get a reference to the Text object and set the .text property to the value of the remaining time.

I'm not sure if this is correct, but it does seem to work, and now the ClientTimer script isn't networked, which resolved the issues with placement of the text.

Source Link

Anchored Unity text ...not anchoring!

I've added some text to a unity UI and set both the achor and pivot to the top right corner as shown here:

enter image description here

When I start this in debug in unity the text looks fine:

enter image description here

What's weird is that when I build the app and run it as an executable as a host (this is a multiplayer networked game) the text also looks fine. But when I start a client instance the text doesn't appear.

I debugged and paused the game in unity in client mode and noticed that the text object is miles away from where I'm expecting it to be (and as a result doesn't show on the camera).

You can just about see the black line on the below image which is my level and the text anchored miles up and right of the level.

It seems like I've done something stupid here but I can't work out what :s

enter image description here