✅ 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
TheRanger2mo 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
ElectricTortoiseOP2mo ago
oh so declare it as a field, then initialise it?
TheRanger
TheRanger2mo ago
yes, also you wont need to pass it as an argument to a method since you can access the field directly
ElectricTortoise
ElectricTortoiseOP2mo ago
omg ok tysm dude i would send you a screenshot but my device decided to hang
ElectricTortoise
ElectricTortoiseOP2mo ago
ok finally managed to unhang my device
No description
TheRanger
TheRanger2mo ago
cool
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
ooo
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
is that why i cant see variables inside a for loop from outside the loop i see
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
i see
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
got it
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
i see
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
but if i want a household item i declare it in House
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo 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 User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
i cant have var a declared twice in the same scope right
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
but outside the scope, var a no longer exists so i can redeclare it
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
public private and such
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo 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 User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
should i ask about it here or in the unity discord
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
understood
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
oh ok im alr in there
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
oh... wait will my class library be functional
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
i need unity to read off my library to generate the UI
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
i see
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
ElectricTortoise
ElectricTortoiseOP2mo ago
thats ok ill go to the unity specific channels ty for the help so far
MODiX
MODiX2mo ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?