Enable Unity's Ui only for the player how triggered it

Hello.

I am having quite a hard time trying to find a solution to my problem.
I am trying to activate a panel with Unity's new UI, but this panel to be active only on the screen of the player who triggered it and not to the others. I am trying to use photonView.isMine but it is not behaving as it should. the problem for this is that if I trigger the panel on a view that is not mine, it shows the panel only on my view, so this is not what I need. I need the panel to be shown only on the screen of the player who triggered it.
Your help would be much appreciated.
Thanks!

Comments

  • If you only need to show it on the player who triggered it, why use network synchronization at all for that?
    You can simply use it like any local UI.
  • Thank you for your answer. The thing is that if I activate/instantiate a gameobject using SetActive/Instantiate this action is automatically visible in all instances of the game. I'm not syncronising anything with PhotonView - but the gameobject is visible for all players. I spent hours to find a solution for this. Would a code snippet from my project be useful?
  • I use network synchronozation in my game for the chat system and I also synchronize many of the actions inside the game, but some UI Panels I preffer them to b visible only local, for the player who triggered it. Is it possible to achieve this using Photon and can you please point me in the right direction of doing this?

    Thanks
  • vadimvadim ✭✭✭
    Hi,
    Remove PhotonView component from UI panel. This will break synchronization and make panels appearance independent on all clients.
  • Hi,
    I have tried this, first thing, activating an UI Panel without any PhotonView Component.
    I even tried activating locally a cube, again without any PhotonView Component.
    In both cases, it is not behaving as expected, both gameobjects are activated on all Player Views, even if they do not have a PhotonView component on them. :(
    So, I really do not what to do next ..
  • vadimvadim ✭✭✭
    Would be interesting to look at simple repro app where cubes synchronized w/o PhotonView's.
    How do you "activate" cubes, by the way?
  • I activate them as I would without any PhotonView component.
    Hitting a collider, OnTriggerEnter(Collier col) and then cube.setActive(true).
  • Hi,

    No one can point in the proper direction of solving my issue?
    Thanks
  • Hi,

    So I've found what is causing the first appearance of a panel for all players, when triggered.
    The player prefab, which I instantiate OnJoinedRoom and which triggers the panel has a PhotonTransformView script and this is set to the Observe option of the PhotonView.
    The Observe option is set to "Unreliable on Change". If turn it off I get the behaviour I need for the UI Panels, but the movement of the character is no longer synchronized.
    So my question is, can I change the Observe option of the PhotonView by script, during game-play? For example, to switch it from "Unreliable on Change" to "Off" when hitting a collider?

    Thanks
  • vadimvadim ✭✭✭
    edited May 2016
    You definitely should separate functionality and decouple gui from player object. So that state of player never affects gui state.
    To change gui state, send messages to it when required.
  • I am also having the same problem
Sign In or Register to comment.