I’m at a bit of a loss with this one and not entirely sure what’s going on. I have a code that calculates colour that runs perfectly fine when I run the first instance of it, but if I reset the values by pressing R, then running the code again, it doesn’t seem to run the DatabaseSearch properly as the computed LAB and computed RGB values remain at 0
I’m not entirely sure what’s going on, any help would be appreciated
Edit - Resolved as it turned out I just needed to attach the script to an object that I could create and destroy. This meant the values didn’t become fixed.
Ok, I setup Debug.Log states for everything that gets reset.
If I press S to start the program, it shows values in computedRGB. When I press R to Reset the variables, it shows computedRGB as 0 (along with everything else as set out).
If I press S again, computedRGB still shows 0 even after DatabaseSearch is run (I know it’s doing something because the program hangs while it’s doing the for loop)
OK you say evrything gets reset but S seems to change the database… so, are you sure thats good? when i said debug, i meant, throw in a lot of commands to see where it goes and what its doing… such as you mention the loop… throw it in, step through it if you have to…
Oh no, I added in the database removal and reinstating it as a troubleshooting step to see if that was the issue i.e unloading it then reloading it back in.
I’m confused by the debug part though, all it is is entering an RGB code and pressing S. Regardless of what RGB I use, it still throws the same error. It just doesn’t make sense why it will run on the first instance, but not again without resetting the player.
I even tried manually rezeroing everything in the inspector without pressing R and it still gives the same issue. It goes through creating the XYZ and LAB, then just returns 0-0-0 when doing the SearchDatabase section rather than the closest RGB values it can find to the target.
All the checkboxes go to true to show that it had completed the search as if it had been run the first time
Ok, So putting the Debug.Log in the for loop in DatabaseSearch shows on the first run through that it’s searching for codes, when I reset it and run it again the Debug.Log shows nothing at all, as if the for loop was never executed
Tried that, Debug.log comes back with i being the value of the length of the database even after pressing R to reset and then press S.
It seems to be getting stuck or skipping something that means it doesn’t crossrefence anything against the database anymore. It’s weird that it does it fine when the program is first initialised, but after that it just doesn’t want to do it.
Ok, I added in SceneManager.LoadScene as a reset, but this doesn’t seem like a viable, long term solution.
It is however…working…
Still, the question remains as to why, if I reset the values back to zero and search again, the for loop gets bypassed for crossreferencing and just goes through the whole database without doing anything
this is why you have to debug it, you need to watch what happens and follow it through its path… spam the s*t out yourself with debug messages if necessary.