I'm working on a PUN 4 player party game where I want to show each player's score at the bottom of the screen.
I created an attribute called Score and added the means to increase it. Then I tested using Debug.Log and I could see each client's score updates in the logs. I have this hooked up to the UI with a script called AttributeTextMonitor, which is basically a copy of AttributeMonitor except using Text instead of a Slider. The UI updates the local player's score just fine.
My attempt to associate a different character with a different UI Score was to add a script that assigns the character's GameObject to the CharacterMonitor's Character property.
The script does hit my breakpoint in AttributeTextMonitor's OnAttachCharacter method and it looks like it's assigning properly. But the UI's score remains tied to the local client's score. I've been trying different things with no luck.
I realize this isn't what attributes were designed for, but once I saw and tested that they do synchronize I was curious about how flexible they could be. A more natural application would be a co-op game where you want to see your partner's HP in your UI.
So a couple questions:
1. Does Attribute system support showing other player's attributes in the UI?
2. How is CharacterMonitor's Character property intended to be manipulated?
I created an attribute called Score and added the means to increase it. Then I tested using Debug.Log and I could see each client's score updates in the logs. I have this hooked up to the UI with a script called AttributeTextMonitor, which is basically a copy of AttributeMonitor except using Text instead of a Slider. The UI updates the local player's score just fine.
My attempt to associate a different character with a different UI Score was to add a script that assigns the character's GameObject to the CharacterMonitor's Character property.
C#:
public class UIAttacher : MonoBehaviour
{
private PhotonView photonView;
void Start()
{
photonView = GetComponent<PhotonView>();
GameObject PlayerUIRect = GameObject.Find(string.Format("P{0}Rect", photonView.ControllerActorNr));
foreach (AttributeTextMonitor attributeTextMonitor in PlayerUIRect.GetComponentsInChildren<AttributeTextMonitor>())
{
attributeTextMonitor.Character = gameObject;
}
}
}
I realize this isn't what attributes were designed for, but once I saw and tested that they do synchronize I was curious about how flexible they could be. A more natural application would be a co-op game where you want to see your partner's HP in your UI.
So a couple questions:
1. Does Attribute system support showing other player's attributes in the UI?
2. How is CharacterMonitor's Character property intended to be manipulated?