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 /
This question was closed Dec 20, 2011 at 08:35 AM by Eric5h5 for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by tostevenwang · Dec 20, 2011 at 06:47 AM · errordocumentation

Code Mistake in documentation

In the scripting documentation, section "Overview: Performance Optimization",

The C# code under: "Here foo will be dynamically typed, thus calling the function DoSomething takes longer than necessary - because the type of foo is unknown, it has to figure out whether it supports DoSomething function, and if it does, invoke that function."

MyScript foo = GetComponent();

should be:

MyScript foo = GetComponent() as MyScript;

Comment
Add comment · Show 3
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 syclamoth · Dec 20, 2011 at 07:15 AM 2
Share

The whole point of this example is to show that that line is bad code. I don't see your point.

avatar image FLASHDENMARK · Dec 20, 2011 at 08:07 AM 0
Share

I think they are trying to $$anonymous$$ch you about what is a often no-no. The first line is dynamic which is slower than the average grand mom, but the seconds is(yes) much quicker.

avatar image Eric5h5 · Dec 20, 2011 at 08:37 AM 1
Share

This site is for questions. If you find a documentation bug, use the bug reporter app. In any case, the page is quite wrong. For one thing, the text does not apply to C#, which doesn't have dynamic typing. The only reason C# code is there is because most of the code examples are written in Unityscript, then translated to the other languages with an automated tool. For another thing, the "dynamic typing" code isn't actually dynamically typed in Unityscript, as of Unity 3.4. As long as you don't use strings, GetComponent returns the type rather than Component. (Note that C# doesn't have this ability. You have to use generics or cast it manually.)

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

,Unity 2019.1.10f1 cannot open or create HDRP projects on Ubuntu Ubuntu 18.04.3 1 Answer

MonoDevelop Error Underlinings for *.js 0 Answers

Pause Menu Script Help? 4 Answers

The type or namespace name 'MonoBehaviourPunCallBacks' could not be found (are you missing a using directive or an assembly reference?) 1 Answer

Console error with animation 1 Answer


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