Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tepei · Oct 04, 2014 at 11:33 AM · photon

Stream Send receive variable via photon cloud in js script

I search everywhere but could never find a working code in js script.

I need to send and receive a variable via photon cloud.

My photonnetwork is already in my Plugin folder..

Thanks for any tips !)

Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image siddharth3322 · Oct 04, 2014 at 11:41 AM 0
Share

Are your imported package is in js or c#? Because as per my knowledge photon provide plugin in c# only.

In C#, I can help you in photon.

avatar image Tepei · Oct 04, 2014 at 11:52 AM 0
Share

The Package is in C#. But as what i have read we can use this package and coding in js script also.. But nowhere i could find a working code in js.

avatar image Tepei · Oct 04, 2014 at 03:09 PM 0
Share

Like most of time i must said the error is $$anonymous$$e...

$$anonymous$$y photonnetwork was in my plugin folder.. But so stupidly i forget that my js script is first in execution order...

So now i could have import Photon.$$anonymous$$onoBehaviour; with no error..

I suppose now i'm gonna find some working code !)

avatar image Tepei · Oct 05, 2014 at 01:47 AM 0
Share

Now i'm trying this:

   function OnPhotonSerializeView(stream : PhotonStream, info : Photon$$anonymous$$essageInfo )
         { Debug.Log ("photonserial");
             if (stream.isWriting)
             {stream.SendNext(test);
              Debug.Log("send");}
             else
             {test = stream.ReceiveNext();
             Debug.Log("receive");
             }}

But none of the debuglog appear in the console... ;(

avatar image N1warhead · Oct 05, 2014 at 02:57 AM 0
Share

I would honestly advise just doing it in C#. There is literally almost no documentation for either C# or Unityscript, and the little documentation there is, is for C#.

Don't feel bad, I started with C# in Unity, then converted to Javascript because there were more tutorials on it. Then when I found Photon, it got me back into C# and now I can program better than I ever could.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tepei · Oct 05, 2014 at 01:14 PM

I finaly get it !!! !)

So here's my way to do this : a: 1/ import photon cloud

2/ Drag the PhotonNetworks folder and the UtilityScript folder in the Plugins folder

alt text

3/ erase the Demos folder !
It will make a lot of error even if you don't use the script inside.. Erase and have a copy or find a folder where it stop to bug ... ... :)

(Another way could be to change the ProjectSetting/scriptcompilationorder to make the Js script compile after the C# script.)

b: Now to send and receive the variable your object must be the player you instantiate. If it's a common gameobject only the first player would send information.

c: Probably you have Drag the photonview script in your player game object then drag your player gameobject (transform) in the photonview script. To communicate move rotation..

Now drag again a photonview script to your player game object ! Now drag the js script component in the new photon view script !

d: here's the code :

 function OnPhotonSerializeView(stream : PhotonStream, info : PhotonMessageInfo )
     { Debug.Log ("photonserial");
      
         if(stream.isWriting){
             stream.SendNext(GameMaster.test);
             Debug.Log("send");
             }
         else{
            
             GameMaster.test = stream.ReceiveNext();
             Debug.Log("receive");
        }

and it works !)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tepei · Oct 08, 2014 at 02:23 PM 0
Share

Yes it works .. But a use a static variable from a common object in the scene.. $$anonymous$$aybe this could cause bug.. Every player is gonna change this variable; but we don't know wich player have the last good value.. So a new player could reset it for all the other's... It works for a normal variable inside the player...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Changing Server/Network type. 1 Answer

If a player triggers a new map loaded, does all players join this new level ? (Photon mutliplayer) 1 Answer

how to change the character in photon angry bots demo? 1 Answer

Photon RPC problem... 3 Answers

Photon spawning issue [weird] 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges