Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Karnareth · Mar 23, 2019 at 10:06 PM · gameobjecttransformerror messagegetcomponent

Getting a huge amount of errors regarding contained definitions in GameObject

I'm fairly new to Unity, but this one strikes me as particularly weird. Suddenly, all my scripts are getting similar errors. Here's a snippet of one of them:

 GameObject b = Instantiate(arrayOfPrefabs[i] as GameObject);  //Cannot convert from 'GameObject' to 'UnityEngine.Object'
             b.transform.SetParent(transform); 
             b.transform.position = transform.position; //'GameObject' does not contain a definition for 'transform' and no accessible extension method 'transform' accepting a first argument of type 'GameObject' could be found 
 
             Color c = b.GetComponent<Image>().color;
             c.a = 0;
             b.GetComponent<Image>().color = c;
             if (b.GetComponent<Text>())
             {
                     c = b.GetComponentInChildren<Text>().color;   
                     c.a = 0;
                     b.GetComponentInChildren<Text>().color = c;
 
                     b.GetComponentInChildren<Text>().text = "sdf";
 //'GameObject' does not contain a definition for 'GetComponentInChildren' and no accessible extension method 'GetComponentInChildren' accepting a first argument of type 'GameObject' could be found             
              }

In some of these there's also the following quote: "(are you missing a using directive or an assembly reference?)", but my using statements are the same as they were when this code worked, it kind of happened all of the sudden, all at the same time. I tried reimporting all assets but it served for nothing. I'm absolutely lost, any help would be greatly appreciated.

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
1
Best Answer

Answer by Hellium · Mar 23, 2019 at 10:40 PM

Are you sure you haven't declared a class called GameObject in your project?

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 xxmariofer · Mar 23, 2019 at 10:43 PM 1
Share

this is the error for sure. try changing GameObject for UnityEngine.GameObject, if it works search for your custom GameObject class

avatar image Karnareth xxmariofer · Mar 24, 2019 at 05:25 PM 0
Share

That was it, I must have panic-clicked some suggestion in VisualStudio and couldn't find it among the other stuff. Thanks a lot.

Now, I'll go repeatitively headbutt a wall or something.

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

175 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycast to Disable Script 0 Answers

NULL REFERENCE EXCEPTION,NULL REFERENCE EXCEPTION while accessing child objects unity2D 0 Answers

Getting errors when referencing a variable. 1 Answer

GameObject not working with variable in C# script 3 Answers

How to mark the vertices on a mesh and make the markers follow them as you apply transformations 0 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