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 Karavans Games · Aug 19, 2013 at 10:37 AM · tutorials

Is Unity Intermediate Scripting tutorials still revelant to UnityScript users ?

I am trying to follow those tutorials (http://unity3d.com/learn/tutorials/modules/intermediate/scripting), but I find myself thinking if it was only made for C# users ?

What I mean is, does this tutorial only apply for C# users since it is teaching OOP ? I found myself trying the Inheritance tutorial in javascript and I was greeted with several errors and warnings.

First, creating a class without derivating from Monobehaviour in javascript is not possible, but in the tutorial it was. I got an error saying that my class needed to derivate from MonoBehaviour or else Scriptable object.

Second, the "new" keyword when instancing a derivated class apply also for a C# usage. It will work for Javascript, but I get a warning message telling me to use instead AddComponent.

Third, the tutorial don't tell me how to make it work in Unity Editor. Do I need to only attach the FruitSalad class to an object, or do I need also the Fruit and Apple Class to be also attached to that game object.

What do you think ? Is OOP still be possible in javascript with these tutorials ? If not, what could be the right piece of code I should use if I want to program OOP javascript for that tutorial ?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by JamesB · Aug 19, 2013 at 11:11 AM

The intermediate scripting tutorials are more focused on C# at the moment, but not all of the lessons will apply to C# only. As you progress in game development it becomes more important to know more of the features of the language that you use. As the examples from the tutorials show, features like inheritance can be very powerful in helping you create games. Unfortunately we simply don't have the time to cover everything in every language. As such we had to choose the language that would make everything that each script was doing as clear and plain as possible. Since there is a lot that is hidden in javascript (for example the implicit class declarations) we went with C#. In order to make a javascript not inherit from monobehaviour you need to make an explicit class declaration.

I'm not sure, but it sounds like you might be a little confused over the use of classes in Unity. All scripts that are attached to gameobjects are monobehaviours. This means that they inherit from the monobehaviour class. This is quite obvious (once you know about inheritance) in C# since you can see : MonoBehaviour at the top of every class declaration. However, in JS, since the declaration is implicit this isn't as obvious. If you try to create a "new" instance of a monobehaviour then you will get the error that you mentioned.

My honest advice in this situation would be to have a go at C#. That may seem daunting or unpleasant (you've already spent the effort learning JS, so why should you bother?) but it will be worthwhile in the long run. Having already learnt JS, you're more than halfway there! Before intermediate scripting, the differences are pretty much just variable and function declarations. They are all summarised in the beginner scripting lesson comparing the two languages.

Again, this may sound like a lot of effort, but it's less than you think and it will be worth while in the long run. Think of how much more powerful your games can be with all the OOP tools working for you!

I hope this helps.

Comment
Add comment · Show 2 · 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 Karavans Games · Aug 19, 2013 at 12:04 PM 0
Share

Hi ! Thanks for the advice. You answered well my concerns, but I was also wondering why the javascript/Boo conterpart of that tutorial was available also for users? It confused me in a sense, because I thought it would be possible to do OOP with unityScript but in a sense the tutorial applies more to C#. Do you know why ?

avatar image JamesB ♦♦ · Aug 19, 2013 at 12:41 PM 0
Share

Later on in intermediate scripting and advanced scripting, there will be some concepts and practices that will be based on things learnt for the language at these earlier stages. We would love to try and do tutorials in js and boo too, but we simply don't have the time. Ins$$anonymous$$d, we'd prefer to make tutorials in C# and translate them as best we can. Sometimes things don't translate at all in which case we put a comment to that effect. Otherwise we will try to translate it into js and boo so that it most closely fits C#.

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

17 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

Related Questions

How to get AI ( Boots ) 1 Answer

Need some pointers towards basics. 0 Answers

Can anyone give the help me with the full Movearound.javascript? 0 Answers

Tutorials Don't work. 1 Answer

Space Shooter Tutorial Lessons 2 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