✅ how do i read a global variable

as you can see, my code currently relies on a variable which is passed byref, but i would really rather it be a global variable. i get an error when i try to do that though
No description
44 Replies
TheRanger
TheRanger2d ago
you defined rookLookup only in the constructor, which means it only exists in that constructor, you need to define it as a field
ElectricTortoise
ElectricTortoiseOP2d ago
oh so declare it as a field, then initialise it?
TheRanger
TheRanger2d ago
yes, also you wont need to pass it as an argument to a method since you can access the field directly
ElectricTortoise
ElectricTortoiseOP2d ago
omg ok tysm dude i would send you a screenshot but my device decided to hang
ElectricTortoise
ElectricTortoiseOP2d ago
ok finally managed to unhang my device
No description
TheRanger
TheRanger2d ago
cool
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
ooo
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
is that why i cant see variables inside a for loop from outside the loop i see
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
i see
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
got it
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
i see
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
but if i want a household item i declare it in House
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
so i can use it in both kitchen and bedroom im pretty sure ive been doing this subconciously without realising lol also cuz it gives me the red squiggly line every time
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
i cant have var a declared twice in the same scope right
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
but outside the scope, var a no longer exists so i can redeclare it
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
public private and such
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
yes ik about that mostly using public and private tho oh wait i am making this a class library i intend to stick it into unity for the GUI
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
should i ask about it here or in the unity discord
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
understood
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
oh ok im alr in there
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
oh... wait will my class library be functional
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
i need unity to read off my library to generate the UI
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
i see
Unknown User
Unknown User2d ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2d ago
thats ok ill go to the unity specific channels ty for the help so far
MODiX
MODiXthis hour
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?