Photon Unity Networking > Utility Scripts > PhotonPlayer > PlayerRoomIndexing

Options
I am using some of the functionality of this Utility script. I prefer in my project to copy the original scripts over to my own project structure with just the items needed, so I do not destroy the originals.

I am having trouble bringing over this scripts functionality.

I removed the namespace, and changed the class name (leaving the copyright info intact) after copying this to my own c# file. Trying to add this to a GameObject without the namespace gives the following error.

"Can't add script behavior PlayerVariables. The script needs to derive from MonoBehaviour!"

It does indeed not derive from MonoBehavior, but instead from PunBehavior. This is not a problem when adding the original script to a GameObject.

As the only difference I could see was the absence of a NameSpace, I simply added one of my own in place of yours. This allowed me to now add the script to a GameObject (which I find strange) however, it is now lacking the behavior your original script did n the Inspector.

1. What am I doing wrong with the cutting and pasting?
2. How would I accomplish my goal (a copy of your routine in my project structure)
3. Why/how does using your Namespace bring about extra functionality in the inspector?
4. The code snippet has a copyright indication. What are the consequences of using a modified version of this in our code? Are these examples allowed to be used without royalty? Can the copyright notices be removed?

Comments

  • Hi @Spektre,

    "Can't add script behavior PlayerVariables. The script needs to derive from MonoBehaviour!"


    Which version of PUN are you using? According to the changelog, PlayerVariables has been removed with 1.82 which has been released in April 2017.

    [...] it is now lacking the behavior your original script did n the Inspector.


    There is a related editor script called PlayerRoomIndexingInspector, which does the visuals. You will have to port this one as well.

    4. The code snippet has a copyright indication. What are the consequences of using a modified version of this in our code? Are these examples allowed to be used without royalty? Can the copyright notices be removed?


    Please take a look at the Photon License Terms, especially 3.2.
  • Spektre
    Options
    The PUN version is that downloaded from the asset store on or about August 1, 2018. How do I find my PUN version?
  • Spektre
    Options
    In a chm file, it is listed as PUN 1.91
  • Spektre
    Options
    Also, how does one attach a PunBehavior derived class to a GameObject without encapsulating in a namespace? Why does the namespace have any effect on this?
  • Spektre
    Options
    No luck extricating this mess. The "Utility Script" follows a rabbit hole of references down. As a suggestion for future releases, "Demos" should be relatively self contained, else they cannot be adapted. I will have to attach and modify the original library scripts which means they will not be within my project structure and as I modify them, I will lose the originals. This isn't optimal.
  • Spektre
    Options
    Since the thread on another topic got closed, I'll try here.

    Has anyone used this utility? It seems to work fine upon creating and joining a room, but after leaving , and creating and joining a new room the results become somewhat random.
  • Spektre
    Options
    To further characterize this behavior, Upon entering a scene I Photon Instantiate the players characters, and then on an attached script in the Start event try to turn one of the many colored components attached to the object to designate which player it is.

    The color turned on is to correspond to the value returned by the above utility such that player 1 is a certain color, player 2 is a certain color and so on with these numbers mapped to players being consistent on all clients.

    The problem I am running into, particularly for players who join a game already in progress, is that this value often returns a -1, despite the fact that the player clearly IS in the room as evidenced by, 1. He loaded the scene automatically (as AutoSyncScene is set) 2. He Photon instantiated a player.