|
Hey, I have a system where three scripts are placed on one parent object and reference each other using a technique like this: From the first script:
From SakiCharacter.js:
This was working fine, until I realized a few things were chugging and decided to optimize based on the instructions in the Performance Optimization guide. I added the #pragma strict line to the beginning of all the script files, and now I'm getting the error from the title of this post. I declared the variable in the other Component! This also affects functions, arrays, and class instances, not just variables. It makes sense that with #pragma strict, it wouldn't be able to find added-on members, at least with some modification. But I've tried everything I know and I'm fresh out of ideas. Any clues on how I can get my own Components' members to be recognized and referenced by code in other Components? Thanks!
(comments are locked)
|
|
Character is a Component because you told it to be; that's not what you want. (Also, variable names should be lowercase, by convention, not uppercase. camelCase is also the standard, not word_wordAfterUnderscore) And don't use quotes in GetComponent; it's slower, unnecessary, and clutter. Finally, using Reset instead of Awake means you don't have to run GetComponent at the start of the game, too.
(comments are locked)
|
