|
Post by westingtyler on Jan 25, 2023 0:02:48 GMT
I'm making an Editor script with a context menu function that will get some info from my sqlManager. I put in some cases to catch the null reference exceptions like the one shown about the column. the script finds the table but will not find the column Orientation. As seen in the image, even the database in LocalLow has the orientation column. I even changed both instances of the word Orientation - the one in the script, and the one in the LocalLow sql, and even the one in the unity assets folder - to say Biscuit instead, and then it kept saying it could not find the Column Biscuit. I cannot figure out why it just will never find this column. The answer in the FAQ didn't really match my case.
I have other editor scripts that work just fine getting SQL queries, but not this one.
Also if I have Overwrite If Exists checked, as soon as I go into play mode it says it can't find the database at the working path, so if I make changes to the SQL I have to manually copy it over the one in LocalLow. there's no start or update function on this script. just a public void, then a couple of bool functions to check if the table exists, and if the column exists. no errors occur upon entering playmode except for that one about not finding the database.
Also where does Unity pull the database from in Editor mode?
|
|
|
Post by echo17 on Jan 25, 2023 10:25:55 GMT
SimpleSQL isn't designed for editor usage. The runtime component copies the embedded project database to the application's persistentDataPath in the Awake method, but that doesn't apply for editors. It really isn't structured for that use case. I'm curious how you are using the runtime component in an editor script. I can take a look at your project to see if there is any way to make it work, but I'll have to see a working example to give you a good diagnosis. Please see this FAQ: link
|
|
|
Post by westingtyler on Feb 4, 2023 22:53:09 GMT
My use case is that I am creating a biome foliage scatter editor script with context menu functions such as ScatterTrees(). I have the details for each type of plant prefab stored in a SQL database. when I am instantiating the prefabs, for each one I need to check its SQL column entry in the database to determine if the prefab should be standing straight up, like a tree, even if spawned on a slope, or if the prefab should hug the ground, like a fallen branch or roots would, lying down flat. each of the 160 or so plant types I have, each being a prefab, has its own Orientation string in the sql. Prior to this script I have another called BiomeCardPopulation where I have a folder of my prefabs, and the script checks if the table and columns exist before retrieving info of their CategoryType, which is used to populate Lists on a scriptable object called BiomeCard. this has been working just fine in the editor, without entering play mode. I right click on the script, click the context menu function PopulateABiomeCard, and it works perfectly. I haven't tested this since having the issues with the new BiomeScatter script, but I am in the process of merging all these scripts into one (GeneratePrefabsFromBlendFile/PopulateBiomeCard/BiomeScatter). I can send the script once it's fully working.
The other thing is, and I'll test it right now. is that for my BiomeScatter script, when I click to do it, if there is no sql in LocalLow, it creates that file there. To get around the detachment issue, part of what I have been doing is to delete the LocalLow file whenever I change the database file's entries in the assets folder, then it adds it back, since overwriting gives the error - and going into play mode gives the error, but only with the BiomeScatter script, even though neither of my scripts has a start or update functoin in them.
if needed it would take longer to assemble a project, but I can do that eventually when all those files are coherent. If it helps I could also post a video showing my use case with an audio description of it, showing the scripts I am using and the editor. for now I can attach here the BiomeCardPopulation.cs, which DOES work in the editor using its context menu function in case this helps make sense of it. I've also attached the BiomeScatter.cs that causes the issue, though it is not cleaned up as much as I'd like yet, having big commented sections. line 512 in that script, I think, is what causes the issue, or doesn't retrieve anything or causes the detachment issue. I can try to provide more as I can put it together if desired.
|
|
|
Post by echo17 on Feb 6, 2023 11:35:27 GMT
Without seeing a working project, I will not be able to diagnose the issue. Again, SimpleSQL was not designed for editor use so any issues you have while in editor mode are likely due to this. I honestly am not sure how you were able to get it to work in editor mode since all the code is structured around Unity's runtime life cycle which does not apply to editor mode.
If you do have a working script that can handle the editor, then I would suggest comparing what works with that to the script that doesn't. My process is to start fresh from an empty project and work up until the problem shows itself. Sometimes it is just a piece of code or setting that crept in causing the issue.
|
|