- Home /
Is every Script I drag on a Gameobject an instance?
Hey,
When you usually program in C#, you can make a class
public class myClass : typeOfClass { }
What I dont understand (I also checked this site) is:
Is every Gameobject which I put my Script on an instance of the class that is defined in the script?
Im sure it is like this, but I really would like to also hear it from someone else =)
The way I see it, which could be totally wrong though, a game object has a whole bunch of inherited classes (Object, Behaviour,Vector3, Collision,...) and when you add a script you add a new class to it with its own variables and functions.Difference is the other objects do not inherit it. This is my simplified vision, obviously it is a little more than that.
Answer by rutter · Jul 17, 2012 at 08:08 PM
Each component on a GameObject represents an instance of that component type. So, yes.
This can lead to complications if you need some way to tell them apart, but there's usually some way to manage it.
allright, that's what I wanted to hear and the same thing u just said about telling them apart is one thing that was confusing me because you do not really name them. But from the aspect that they ARE instances I can imagine that they and how they are differenced.
Your answer
Follow this Question
Related Questions
How to add new instance of a script to a game object? 2 Answers
Enter Class(method) with a script, attached to another Object 2 Answers
How to add an existing script instance to a GameObject 2 Answers
Restricting "Drag GameObject" script to Z Axis? 1 Answer
Script Execution Order doesn't affect derived classes. 1 Answer