• 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
-1
Question by YingXinLi · Nov 24, 2016 at 04:26 AM · transformdefinition

how can I fix this errors?

When I import this script into Unity, it shows that Type 'UnityEngine.GameObject' does not contain a definition for 'transforms' and no extension method 'transforms' of type 'UnityEngine.GameObject' could be found. How can I fix this problem? alt text

capture.jpg (59.2 kB)
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

2 Replies

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

Answer by aditya · Nov 24, 2016 at 06:16 AM

Because there is no method named transforms but transform in GameObject class ... remove letter s form there

Accept if helps

Comment
Add comment · Show 4 · 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 YingXinLi · Nov 24, 2016 at 06:30 AM -1
Share

Hi! Thanks for the help! But after removing all "s" in the script, and I re-imported it into Unity, it says that The name 'Oceanplane' does not exist in the current context. I have renamed the Plane to 'Oceanplane', but still not work. Why's that?

avatar image aditya YingXinLi · Nov 24, 2016 at 06:41 AM 0
Share

in you SeaLevelChange method, change Oceanplane with OceanPlane in the section where you are trying to fetch the z element of position vector .... in short, replace small p with capital P ... BTW what code editor are you using ?, i think your autocompletion is not working

avatar image YingXinLi aditya · Nov 24, 2016 at 06:49 AM 0
Share

Thanks so much! I re-imported it this time and no error shows up, but I haven't run and tested it. I m using the $$anonymous$$icrosoft Visual Studio to edit it. Why you think that not work??

Show more comments
avatar image
0

Answer by upasnavig90 · Nov 24, 2016 at 08:05 PM

use transform instead of transforms :

public Slider seaLevelRiseSlider; public GameObject oceanPlane;

 private Vector3 _seaLevel;

 void Start()
 {
     _seaLevel = new Vector3 (0,0,0);
     _seaLevel = oceanPlane.transform.position;
 }

 public void SeaLevelChange()
 {
     SeaLevel = seaLevelRiseSlider.value;
     oceanPlane.transform.position = new Vector3 (oceanPlane.transform.position.x,SeaLevel*10,oceanPlane.transform.position.z);
 }



 public float SeaLevel
 {
     get {
         return _seaLevel.y;
     }
     set {
         _seaLevel.y = value;
     }
 }
Comment
Add comment · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Using deviceOrientation to calibrate Camera 0 Answers

What is the reasoning of multiplying by Time.deltaTime 1 Answer

Accessing children of instances vs children of original prefab 1 Answer

does not work check if dead 1 Answer

getting object local direction? 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