x


Am I supposed to see member variables and methods from other scripts?

I have a script that simply declares some variables, outside of functions-- just meant to be member variables. ScriptA, let's call it.

I attach it to an object.

In that same object, in a different script (ScriptB? Sure, why not?), I get ScriptA component, but when I try to get a variable or call a method, MonoDevelop refuses to acknowledge it in autocomplete. However, if I test the game, I can see that the variables and methods are being called.

I tried resyncing MonoDevelop, but I'm still not getting any autocomplete... it just forces me to really focus on typos, when I'd rather be focusing on writing code. Plus, I gotta keep jumping to the other script to remind myself of these members.

My code looks something like this:

ScriptA (attached to someObject ):

//these are set in the inspector
var someVar1 : someType;
var someVar2 : someType;

ScriptB (also attached to someObject):

var someVarA : ScriptA;

function Start(){
  someVarA = GetComponent( ScriptA );
  someVarA.//and here I can't get any members of ScriptA!!
}

Like I said, I can still call the members and see the results in console or in game... but I MonoDevelop doesn't show me any of them as I code. Do I need to include the other scripts or something?

more ▼

asked Nov 03 '11 at 09:56 PM

Sinaz20 gravatar image

Sinaz20
1 9 10 12

Monodevelop isn't very good for autocomplete in Javascript. If you mark your members as explicitly public, does that help?

Nov 03 '11 at 11:04 PM syclamoth

No, it doesn't help. Tried turning the variables public, and then tried a resync to be doubly sure.

Nov 03 '11 at 11:20 PM Sinaz20

Autocomplete was one of the biggest reasons I started using C#. Monodevelop is far smarter with C# syntax and autocompletion that it is with js.

Nov 03 '11 at 11:40 PM Peter G

Well, it helps that C# doesn't have fuzzy types like JS does. Honestly, I don't blame MonoDevelop for not knowing what's going on there with JS files, they're so messy!

Nov 03 '11 at 11:44 PM syclamoth

Well then-- I'm early enough in development to port everything over to C#... is there anything right off the top of your head I should keep in mind or read up on about C# in Unity before I begin porting?

Nov 03 '11 at 11:57 PM Sinaz20
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x377
x21

asked: Nov 03 '11 at 09:56 PM

Seen: 658 times

Last Updated: Nov 04 '11 at 12:27 AM