#dict help
1 messages · Page 1 of 1 (latest)
foreach(Vector3Int activeTile in cellDict.Values){ Debug.Log(activeTile); }
add this also
oh yeah and to differentiate make like this
foreach(Vector3Int activeTile in cellDict.Values){ Debug.Log("Dict Values:" + activeTile); }
that shows whats in active list
whats in dictionary as key and whats value in dict
if every value in dict is null, you prob have problem filling dict with values and setup is generally fine
but what i think the problem is, is that only last value in your dict is not null
178 seems to be showing a long list of vector3ints like i would expect, but 177 is only showing 2. but actually that's correct because on my tilemap that i drew from palette there are 2 active water tiles, so that seems ok
i could count them but it looks ok at first glance
dont know lines
foreach(Vector3Int activeTile in cellDict.Values){ Debug.Log(activeTile); }
what does this one say
think its most important
nope
it is erroring then
values just prints out all values
oh yeah
foreach(CellData activeTile in cellDict.Values){ Debug.Log(activeTile); }
right
type mismatch
CellData is value
didnt look but i think this is only place your cellDict is filled
instead of passing initCellData
make it
cellDict.Add(tileLocation, new CellData(put your values here with cell data));
then see if your line 163 still throws errors
one moment
basically create new cellData and then change values to what you want
based on your setup think you will need to do this again
but instead of initCellData you would need to put cellDict[tileLocation].Index = something
in your last comment, when you said instead of passing initCellData, which line?
145
FOR TESTING PURPOSES
cellDict.Add(tileLocation, new CellData());
change it to this only and then run code with
foreach(CellData activeTile in cellDict.Values){ Debug.Log(activeTile); }
in evaluteTiles function
just to be faster and sure
if you understand
and see if its all null still
i'm reading and absorbing lol
i guess i thought i was creating a new cellData in EvaluateTiles then adding it to the dict toward the end...
sure
change only line 143 to
cellDict.Add(tileLocation, new CellData());
then add
foreach(CellData activeTile in cellDict.Values){ Debug.Log(activeTile); }
at start of evaluateTiles
it was all null before
ok let me try that one sec
when you say line 143 you mean the empty line?
err the one with }
np got it
where you add to dictionary
i had disabled, one sec
were you wanting me to replace the line at 145 or just add another one w/ the one you suggested? and actually no dictchecker seems to be reporting all 0,0,0 which is new ( i think it is commenting out 145 tbh)
lemme try uncommenting that and see
wanted to replace but you can return your own line i think
yeah but its not null
how is EvaluateTiles reporting null
ah i think i know what's happening there. new cell data has a 0,0,0 default vector3int but it's still got a tilelocation var you're passing in
idk lol
1 sec testing something
can you paste new code
sure i was just thinking the same. but just for a report: the line at 145 (original) is needed for dictchecker to work. dictchecker reports all 0's without it etc. but with both dict add lines it throws error bc vector3int already exists in dictionary, but the one that you gave me doesn't actually associate w/ an existing celldata.
if i give you a code update it will look a lot like the original bc i commented some stuff out to test. you want me to send you a version f the one that wasn't working w/ your suggestion? sorry i don't mean to be confusing
the v3i is the key
for the dict
send current version
ok, run program like it is and tell me what DictChecker says
then swap commentes on these lines
and do it again
76x default value (0,0,0). i don't see how it could be adding the data with a new celldata..
without populating it after
my strategy is to look at the tilemap and create a data file for each that exist at start, and assoicate w/ a vector3int and flag some of them as 'active' then in evaluate tiles i am going over that list of active tiles and pulling up the data file (class), applying changes as needed, and adding it back to the library. if no data file exists for a given vector3int in evaluatetiles(), then something has gone wrong already according to my strategy
err, when i say adding it back to the library, i meant updating the dict entry
slight misspeak there: if no data file exists for a given vector3int that has a tile, something broken
that is with active line 166
and with 167?
do they both report error on new line 192?
no with both it throws a red error bc the key for the vector3ints already exist
that makes no sense
lemme double check but yeah 192 is always reporting problems so far
i know right?
yeah it's throwing critical errors for the two active tiles in the list (from line 192)
not actual critical errors they're my own
makes no sense since DictChecker reports every cell.Position to be 0,0,0
yet evaluate reports them as null
foreach (Vector3Int key in cellDict.Keys) {
Debug.Log("For key:" + key);
Debug.Log(cellDict[key]);
Debug.Log("Is active?" + activeTileList.Contains(key));
}
can you add this at end of DictChecker
and report what does it say?
sure 1 sec
so the first part for key is reporting all of the v3i's apparently but there are no active tiles
it's a lot, bc it's all the v3is
wait
there is no lines that report "Is Active?true"?
i take that back, it's reporting 2/76 as active, which is correct
and it's reporting the other 74 as false
you can do WINDOWS key + shift + s
and you can screenshot only ones that are active
sorry i'm unclear what you want me to screenshot exactly. it's saying Is active?True twice and False 74 times, as well as listing the Vector3Ints
i could expand the list and sceenshot it but why lol
you're being helpful so i don't mean to be diffucult
For key(:Vector3Ints) <---- a list of all of them
for lines that are true
it's not 0s
oh
ah i see now, i had it collapsed, oops
how do i attach my png
sorry i'm new to discord lol
nvmd
idk how to read that exactly
k
seems the same. screen3 is for reference to show it's the same tiles v3i as the ones throwing the error in evaluatetiles
wait did you want my to uncomment 166 without commenting 167?
err, wait, which did you want me to comment lol
ok
that's what it was the first time..
i think. heck i'll just do it again
yep it's the same
either way, apparently. except the top part is 0s when i use the new CellData instead of initCellData, like we talked about before. it's the other debug.log
it's from dictchecker
top part of
sure
a lot of this stuff is obviously unused for now http://pastie.org/p/64m0TdMR7swwXdR8Dzcuha
betweeen these two lines
add
Debug.Log(initCellData);
Debug.Log(cellDict[tileLocation]);
see what it gives out
you got it
see what is actually stored in storing part
to be clear at the moment i have cellDict.Add(tileLocation, new CellData()); instead of 167 .. only one will go.. which should i try first?
k
no need to try new CellData()
k, thought so
i think you found it? both null for some reason
(for all)
yep every 76 tile iterations for both
null
i dont get it lol. all in the same scope wtf
check value of initCellData at line 119
right after asigning it
see if its null there also
do you mean just InitCellData or you want .Position?
just initCellData
k
just checking if its null
that actually looks redundant looking at it,
but that's probably irrelevant
1 sec
ok so this is going to trip you out
i'm getting null on that, but if i do .Position i get vector3ints
idk really know what this means, but is initCellData getting initialized correctly?
if you can debug log initCellData and its null
then debug log its position and its there
yup
idk
hahaha
you know what? i respect that
119 and 120?
what's the question?
debug for initCellData and positon
yes, i did both and the initCellData is null but initCellData.Position shows correct values
a class is something you can just Debug.Log normally right?
by itself..
either way it's showing null in results
so weird
hey
yo
k
public override string ToString() { return "Position of this CellData:" + Position; }
just in vars?
in class script
yeah anywhere in public class CellData
alright it's in there..
when debugging initCellData
type
Debug.Log(initCellData.ToString());
instead of Debug.Log(initCellData);
does it still give you null or ?
does it matter that i'm naming my CellData class instances differently before trying to add them?
what do you mean
like i have initcelldata in the first part and um
in EvaluateTiles i am using thisActiveTileData
it's the same Class
nah
either way i want to say thanks for taking so much time. it's really appreciated.
can you have
Debug.Log(initCellData.ToString());
and right below
Debug.Log(initCellData);
thats lines 119 and 120 i think
and screenshot it to me
idk how you have it right now
just after initializing var initCellData
and giving it values
have those 2 lines
oh right i had those. ok one sec
just commenting out some other debug stuff it's geting crowded
one sec tho
ok so those are both reporting their info correctly
you want a screen?
yeah
screen7 is better than screen6
do the Debug.Log(initCellData==null); instead of Debug.Log(initCellData);
just making sure its null in if
yeah it's reporting true
that's fair, it was still really helpful diagnostic
wait a sec
i've been writing down what does/doesn't work
k
where?
and replace it with this line
//cellDict.Add(tileLocation, new CellData());
no comments
i think its 111 line
should be
cellDict.Add(tileLocation, new CellData());
replace it with this
wait
where you declare dictionary
remove the static part
do it public Dictionary...
this stuff
and leave your old code
k 1 sec
does Debug.Log(initCellData==null); report true if you remove static from dictionary declaration
wait i'm confused. replace var initCellData = new CellData(); with cellDict.Add(tileLocation, new CellData());
??
if i comment the first it throws errors..
dont replace that yet
leave var initCellData = new CellData();
k
only thing to change is to remove static
k
just to test if it messes with dictionary cause i never made static dictionary
dont see why it would mess it up but doesnt hurt to try
without changing anything else it doesn't seem to have done anything
yeah that's returning true
okay
then
replace var initCellData = new CellData();
with
cellDict.Add(tileLocation, new CellData());
thats line 111
that should give you lots of errors where initCellData was
that way you affect dictionary instead of variable
Debug.Log(cellDict[tileLocation]==null);
that should be new debug
i'm getting an error.. one sec
172 in the console is actually 166 in the code i posted. sorry i guess taking out the comments wasn't th ebest idea lol
that was also replaced with cellDict.Add(tileLocation, cellDict[tileLocation]); btw
that needs to be removed
no need to add it twice to dictionary
well, some of the debug stuff was removed, but for the stuff you asked for recenlty
it's still showing vector3ints though
yep
well still reports cellDict[tileLocation].Position correctly
all of em
right
let me double check
and cellDict[tileLocation] == null is true?
yea that's true
well honestly have no idea, since it can get values but it cant get object reference
yes, it does
er
it does report cellDict[tileLocation].Position
well like i said it's been very helpful diagnostic anyway. i'm following what you're doing.
Ask in code-advanced
why
Debug.Log(cellDict[tileLocation].Position); reports position
but
Debug.Log(cellDict[tileLocation] == null); reports true
i will do exactly that, thank you very much again for your time
can give them screenshots as proof
like this one
and screenshot part of code that initializes
cellDict.Add(tileLocation, cellDict[tileLocation]);
assign of variables and then debug
i dont have any more ideas how to debug, never seen this problem before
well at least i feel better about going crazy for a couple days xD
take care, i'll be back i'm sure
yeah sure, post here any info about situation
i would like to see how this is resolved
oh got idea
remove : MonoBehaviour
and then see what debug.log gives
true of false
i think this is problem
@kind cloud
sec
'DataSpace.CellData' is missing the class attribute 'ExtensionOfNativeClass'!
what?
it's in a namespace
yeah
do you create that celldata somewhere
or assign it to some object?
that is problem i think
what you are looking at == null is gameobject which doesnt exist
i'm not sure i understand
okay
do you use CellData
on some object
does some object have variabled public CellData
and then you drag this script to it?
OKAY
for simple resolution
change public class CellData to public class CellDataX
and see what problems come
class with data cant have monobehaviour
since it needs gameobject
nope there are no objects in the scene that have this script on it as far as i'm aware
i could put it on the tilemap or something
then change name to CellDataX
which part, the script itself?
yeah
well unity think CellData is monobehaviour from before
variables
monobehaviour cant be used as regular class of storing data and needs gameobject
what we have done before is checking if class had gameobject but didnt since you used new CellData();
that cant be done
there is but harder to explain
easiest way is to close unity and delete Library folder in your project but that messes other things also
you can later change name back to CellData
when we make sure CellDataX works
when it works you go to CellDataX, right click and choose rename
change name and hit apply
this way visual studio will change class name everywhere
wait you have 2 scripts with public class CellDataX?
no..
think you have 2 class definitions for CellDataX
no it's on line 11 hnag on
just make sure current project is selected
ctrl + f
and search should look like this
ohhh
lol i think might know
wait no
it's def possible i had another class called CellData in a different folder or something but no shot i had one called CellDataX, there's only one
and there's only 2 scripts in this project so far other than the scriptable object
ok
yep just one
hmm cant really tell like this
but there are definitions of CellDataX 2 times
i cant look it up myself hahahah
but you need to remove second one somehow and then it will work
sec
i swear on my life i was doing it right and somehow it didn't detect that unity had made another copy of celldata instead of renaming it (i used f2). welp yeah it's gone one sec
i just found it with the windows explorer
ok i think that did it. i'm getting false now
the copy wasn't showing in the assets folder either
wtf man lol
thing is trying to make me look bad
it's good now
evaluate should work now
oh wait
weird. one sec
gonna just exit both programs
is there something special i need to do to refresh other than restart? it's doing this again
can you make new c# script
copy entire content of current script to that one
and delete current one
leaving only new one
i think this is only problem with unity
i was suspecting that as well
if you understand what iam saying
oh i do
boy do i ever!
sure hang on
let me close both again
what's the best way to cleanly uninstall a package? i have the entities thing install and probably won't use it. i seriously doubt it is causing issues but it is in experimental so..
i'm not actually 'using' it for anything to my knowledge
just deleting it from folder of project
but dont think you need to care about it
btw why are you using DataSpace namespace?
honestly i'm a noob i just wanted to make it so i could have access to it
without always referencing it
via object
remove namespace, not useable
namespace is when you create modular tool that can be used in many projects
so you just import the tool and use it with namespace
namespace doesnt help with referencing, for that, take a look into singleton
object that can always be referenced
k, almost there
ok i've done that. exited everything dragged all but flowmaster out, copied contents of celldatax to new file new name dragged it back, updated references in flowmaster
and gonna open unity again
er, new file, not celldatax obviously
whatever you want
hmmm it seems like it might be working?
remind me what i'm looking for
or i can screen
no errors reported by unity, and i'm getting false plus positions
it means it works
let me see
hey i appreciate it. i never ever would have caught that. not without like 2 courses
not to mention solving it
yeesh
can i rename it again or is unity going to remember celldata still?
i liked that name 😦
yeah change it now
dont think it should cause more issues
unity can act weird sometimes
dont use namespaces until you become good at programming and start creating your tools, its usefull but can overwhelm you
for naming, try to name your script same as your class
ok thanks again. what an annoying issue. i really could have wasted weeks on that. we were at it for like 5+ hours! seriously. thank you.
i'm gonna go make some tea. have a great day. hope i see ya around soon!
i'm gonna go tell the other thread(s) that it's solved