|
Update: Now that I understand more, I would like to make it clear to others who might struggle with this issue.
THUS, CRITICAL: Treat this 'UnityScript' as its own implementation(Unity's). Stay aware that what you know in the world reknown great standard 'javascript' implementation may not apply in 'UnityScript' Example: the word 'static' is a reserved word in 'javascript', 'JScript', Java, etc. but is not implemented in 'javascript' nor JScript' but IS IMPLEMENTED in 'UnityScript'. I am willing to bet that many programming practices we are used to in 'javascript' are not going to work in 'UnityScript' while others which are not available in 'javascript' are possible in 'UnityScript'. To name 2 of the more obvious and important ones: prototyping versus class based inheritance, and closures. ('UnityScript' appears to be class based yet may allow prototyping... don't know, have not had a chance to verify that)... and I believe closures are not available in 'UnityScript' ...someone please clarify and save me the trouble of having to test it... I will update this Update to keep it all in one place. t.y. None of the answers I have gotten or ran into on this issue have been completely clear. They all left me with gaps and questions. Thus I have not upvoted any. The link Mike provides in the answer below is being rapidly updated, and offers the most complete reference I have seen in one place: Unityjavascript. I really wish the name 'UnityScript' were used instead of 'javascript' in the Unity context. (...even if the name 'javascript' serves as a marketing lure...) ~~~~~~ ORIGINAL ENTRY... ~~~~~~ Spun on this too long... something does not add up. My ViewsBar.js creates the toolbar, buttons appear on screen and trigger/change shade on mouse click. All good. Note: I should mention that if one sweeps the mouse pointer off the button before releasing the mouse button, the button still triggers - that is inconsistent with the behavior on other Windows buttons. It gives no chance to cancel the action if the wrong button was clicked. I have never seen a javascript 'static' keyword. - mentioned at this URL in the Script Reference? http://unity3d.com/support/documentation/ScriptReference/index.Member_Variables_26_Global_Variables.html Is it a new version? Is it one of the hidden secrets of javascript? Is there a UnityScript? ...but everything has .js extensions in the Reference. ERROR: Assets/Standard Assets/Camera Scripts/SmoothFollow.js(31,15): BCE0005: Unknown identifier: 'ViewsBar'. How do I read the status of the buttons in the toolbar from the smoothfollow script so I can adjust the camera location accordingly? Scripts: ViewsBar.js
smoothfollow.js
(comments are locked)
|
|
Unity Javascript (a.k.a. UnityScript) is a .NET based language, so the static keyword works with it. For your specific problem, static var toolbarInt = 0; would work, but it sounds like it can't find your script. Smoothfollow is probably the one from standard assets? If that's the case, it can't find your other script because standard assets is compiled earlier You could try moving it out of the folder somewhere else Alternatively - do it the other way round. Have a function on your smoothfollow script which lets you set the current behaviour (from your other script) That means that you're not adding game specific code into the follow script, just adding more features Please be clear as I am now very confused. I use Javascript(ECMA... etc), Live Script from Netscape days) (browser clientside coding and ServerSide). Is Unity Javascript your compiler proprietary version not the ECMA javascript? If so, where the keywords reference for it?. ...your documentation uses the name javascript, that leads me to believe it is javascript, plus all the extensions are js? Please clear up this issue for me, and do not forget to let me know where the ref is... not the tutorials, not the ref called Scripting on the Unity web site... no ref there that I saw.
Jun 27 '10 at 09:35 PM
dingben
It's ECMA-ish, but it's a proprietary Unity only language. The best documentation on the language you'll get is probably in the wiki, here: http://www.unifycommunity.com/wiki/index.php?title=Programming
Jun 27 '10 at 09:47 PM
Mike 3
If only ECMA-ish then not the same, thus problems. geees... I was afraid you would say that... now I have to dig into a new reference set to see if what I attempt to code using my (true)javascript understanding will fly in this version. Before I start digging, can you tell me if classes in Unityjavascript are attained the same way as in (true)javascript by nesting functions/prototyping? ... and are closures also a way of life in Unityjavascript? I am going to start a thread for 'DIFFERENCES between (true)javascript and Unityjavascript'.
Jun 28 '10 at 02:48 AM
dingben
ok... first 2, I understand now. (3)compiles earlier? I don't buy that unless the compiler is an archaic 1 pass compiler. (4)Moving 'it' out, you mean the ViewsBar.js? I have moved it under several folders in the Standard Assets hierarchy. (5)do it the other way around... and what you state is what I am doing already? I even have moved the toobar code in the smoothfollow.js and got it to see the object, but now the buttons work for 2 clicks and then become dead. (6) I am not sure what your last comment about game specific versus feature means?
Jun 28 '10 at 03:53 AM
dingben
the third point is because Unity has multiple passes so that javascript and c# scripts from later passes can use common scripts in either language which are in specific folders. 4 i meant SmoothFollow, into some other folder than standard assets 5 and 6 are the same point, you wouldn't want any toolbar code in smoothfollow as it breaks reusability - if you needed to have 2 objects following things, it'd break things.
Jun 28 '10 at 08:13 AM
Mike 3
(comments are locked)
|

I hit the link button below on the answer, I have no idea what that does nor am I able to do anything with the page where I hit the link, I BACKed here to be able to type this note. How do I reverse the Link button mistake?