PhotonNetwork JavaScript

[code2=csharp]using UnityEngine;
using System.Collections;

public class networking: Photon.MonoBehaviour {
}[/code2]

hi,
cs code in this work. Can you help, but you want to convert to js. js photon can work in this way?
thanks in advance :)

code does not work:

[code2=javascript]import UnityEngine;
import System.Collections;

public class networking extends Photon.MonoBehaviour {
}[/code2]

error:
The name 'Photon.MonoBehaviour' does not denote a valid type ('not found'). Did you mean 'UnityEngine.MonoBehaviour'?

.

Comments

  • You first have to move the PUN "plugin" folder to the base of your project. Then JS can access the classes that are in our code.
    This is also described in the doc (a bit more extensive, if I recall correctly).

    I'm not sure how Unity's JS is handling namespaces. It should work.
  • I've tried the plugin folder. but always get the same error. Please send me a sample project made ​​with java. This is really useful to me.
  • namespaces in JS are 'used' through import.
    js itself does not support namespaces but thats no problem in unity 3 at all as they are not supported anywhere.


    @posepx: Take the Plugins folder within PUN, move it to Assets/Plugins within your project folder so it shows up in the project panel directly as Plugins (must be named like this).

    Also, again, unity does not support java, its unityscript (not even the real javascript). Naming it incorrectly will only lead you to wrong informations on the web, harming your learning experience and productivity significantly
  • Thank you very much. I tried but what does not happen. constantly having this problem:
    The name 'Photon.MonoBehaviour' does not denote a valid type ('not found'). Did you mean 'UnityEngine.MonoBehaviour'?

    I'm doing a mistake somewhere. For example if a project I solve.
  • The error normally means that js tries to use code not found or not present.
    In this case here its cause the Photon Plugins folder is somewhere down the hierarchy and not in the top level in the project panel which is required for Unity to treat the folder as 'plugins' and compile it in the first step so it appears as 'normal .net code that was always present' in the JS code you write afterwards.

    Whats your exact reason for using javascript by the way? (it offers like 1 or 2 benefits while losing 7 of them, hence I'm asking)
Sign In or Register to comment.