- Home /
Is it possible to find gameobjects as .cs?
Hello,
I'm assuming every GameObject I create in Unity gets saved as a class file somewhere. I'm assuming that class file would have each component as a class variable.
Am I right? If so, where would I find these scripts?
Thanks in advance!
Edit: Alternatively, can I access prefabs as .cs files?
Answer by Captain_Pineapple · May 29, 2020 at 12:54 PM
In general no, this is not how unity works. Each scene is basically a text file defining which object has to be where and which components are on it with a given set of data that defines the global variables of each component.
This however is only accessible as a saved file when you save a scene. In playmode this is not available afaik.
prefabs work in a similar way. But unity does not create new c# code based on components, prefabs or scenes.
But are the object in each scene not defined as a class? How are they defined?
Perhaps you have to specify a bit more specific what you mean by "object in a scene" Did you ever open a scene with a text editor? Thats all there is. When unity loads the scene this all gets translated and loads objects accordingly. After this you mostly only navigate in compiled (thus binary) environment.
perhaps if you added what you actually need this for people might actually offer you a solution for you actual problem.
I'm making an U$$anonymous$$L class diagram :)
I'm trying to figure out how I'd link different gameobject and components to eachother.
If you want to boil down what I'm asking, it's this: do instanced GameObjects count as objects or are they seperate classes? What about prefabs?
Your answer
![](https://koobas.hobune.stream/wayback/20220612235555im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Instantiating gameObject with custom Class properties 1 Answer
How to access an instance of a class when the class isn't known 2 Answers
I have everything in the right place but why wont my value stay changed ? 2 Answers
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
How unity works under the hood? 0 Answers