I seem to be running deadstraight into wall after wall with trying to figure this out. Searching points me to topics that have either nothing to do with what I want, or ones that I have looked at already.
1 : How do I use variables created outside functions in another file?
2 : What is the difference and limitations of variable types (private, public, ect)
3 : How do I use functions from 1 file in another? What if they are in a different gameobject?
4: What is the difference and limitations of function types (private, public, ect)
Everything in one file is in one
All of your scripts are a subtype of
Once you have a reference to your custom component type, you can then call functions and access variables just like anything else.
As a basic example:
Notice there's no
In another script that's attached to the same game object as the above is, you can do this:
And that should be obvious what that does. However you won't be able to call the private function, or access private variables with a reference to your class.
If that script is on another game object, first you have to get a reference to the game object that your script is on. From there it's the same, you would just call
answered Jul 14, 2010 at 04:40 PM