✅ 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

44 Replies
you defined
rookLookup
only in the constructor, which means it only exists in that constructor, you need to define it as a fieldoh so declare it as a field, then initialise it?
yes, also you wont need to pass it as an argument to a method since you can access the field directly
omg ok tysm dude
i would send you a screenshot but my device decided to hang
ok finally managed to unhang my device

cool
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
ooo
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
is that why i cant see variables inside a for loop from outside the loop
i see
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
i see
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
got it
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
i see
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
but if i want a household item i declare it in House
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
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•2mo ago
Message Not Public
Sign In & Join Server To View
i cant have var a declared twice in the same scope right
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
but outside the scope, var a no longer exists
so i can redeclare it
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
public private and such
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
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•2mo ago
Message Not Public
Sign In & Join Server To View
should i ask about it here or in the unity discord
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
understood
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
oh ok im alr in there
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
oh...
wait will my class library be functional
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
i need unity to read off my library
to generate the UI
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
i see
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
thats ok
ill go to the unity specific channels
ty for the help so far
If you have no further questions, please use /close to mark the forum thread as answered