Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

Prefab thumbnail can't be created

A topic by walkingsolutions created Nov 02, 2019 Views: 171 Replies: 11
Viewing posts 1 to 6

When trying to add the script to prefabs and add them to the selection panel they end up being transparent. Checked the logs and can see it Throws a permissions error regarding writing the png files, despite granting all possible perms to Unity and the system authenticated user. Permissions don't actually seem to be it's problem, as i was trying several approaches to see if one would give before i tried pulling apart the code - and it seems when you CONVERT mesh's to Prefabs and THEN import t hem it all works well, so whatever failing we have in the add script phase it's avoided in the full Mesh > Prefab > Scripted > Selection Panel.  Unity 2019.2.0b9 (project dedicated to testing this potentially mind blowing tool)  :P

Maybe I'm just tired, but was having a hard time following your post.  Maybe bullet points?  Hehe

I'm suspecting this is simply because the camera isn't pulling back to take the snapshots.

  • The snapshot camera pulls back to fit the bounding box of the model.
  • A bounding box doesn't exist without a collider on the prefab, so make sure there is some sort of collider added.
  • The button that creates prefabs from raw models adds a mesh collider to each one, so those would meet the requirements.

Let me know if manually adding the mesh colliders works for you.  I can imagine that there will be times where a user won't want/need a collider, so maybe I'll have the generate thumbnail class add colliders to any prefabs that are missing them, just for the photo. =)

I thought that might be it but haven't slept in a while so my  brain is falling over,  thanks Keith! :)

Confirmed, the thumbnail issue is related to mesh bounds, so we can run a meshbounds check and inverse scale the mode, easy :) also found a bunch of disk write errors  that i thought were the cause for problems, but it's actually just you doing some maintenance on a null ref, and it's not actually causing any problems at all., it just happens to throw errors around the same time other things are breaking  :) 

(1 edit)

I would like to know what these disk write errors are that you're referring to.  After the thumbnails are generated, MAST does save each thumbnail as a PNG in MAST/etc/temp.  Is that what's throwing the error?

Error below, i looked at the code thinking this was the cause of blank images but as i played with the system further i realised it's because submesh model generation leaves the mesh bounds unchecked so really you just need to recalc bounds when importing, so that was next on my list of things to do.

Your code is just cleaning up some temp data but the method throws the Denied, because you're trying to delete a dir and my guess is those things are currently open by the engine etc, and for a couple of years now Unity has strongly recommended you don't write to the local project dir because of permission issues with Windows, now personally in my projects i _do_ but that's because i know how to set windows permissions and how to write code that doesn't invoke problems like this, which was a long trial/horror thing :)  for one thing don't shortcut file cleanup with a request to delete the entire directory and re-create it, a permission / security model will absolutely scream about that because it's massively aggressive, and specifically with the recursive flag, that's the sort of stuff that requires root administrator privs in any system because it can destroy an entire o/s partition in no time at all, what if the dir contains a broken link to the root? maybe a symlink won't do that but what about junctures or the 6 other types of low level system links? what about system links that don't exist yet? it's a fairly remote chance but the outcome is apocalyptic so that makes it mad high risk :)  and it's a design approach problem anyway so you don't even need that risk, a better option is to manage state caches, don't delete anything because you're forcing a rebuild and discarding "progress", which is wasteful, just manage what you're displaying and manage a cache queue so if something changes then invalidate that particular item and pick it up in your rebuild schedule.  So it does create thumbs anyway, it just doesn't orient the models so in my case they're miles from origin on this kitbash set and since most kitbashes come in this form i'm looking at coming up with a splitting system to handle this.

Also unity has some standard paths you can use for this sort of thing, StreamingAssets is where you write stuff like this, or the user path, I can understand why you wouldn't want to use the user path, that's the dumbest thing that has emerged from game development, as if a users profile capacity is infinite and that you want 5 gigs of save files per game to occupy your high priority offsite DR/backup schemes.

Here's your code that emits the error;
string paletteImagePath = MAST_Asset_Loader.GetMASTRootFolder() + "/Etc/Temp";
if (Directory.Exists(paletteImagePath)) { Directory.Delete(paletteImagePath, true); }

then it's onto extending that interface,  I need all objects at all times :) I mean this is literally Unity's problem, horrific navigation systems, so if i have to use those same nav systems to locate my resources to put into your wonderful interface - it's just adding an extra step in an already nightmarish navigation hell, so i'll see what i can do and then ship the code over to you :) May need to modify the UI resizing code a bit, the most sensible setup for me is a vertical list snapped to the left, but the buttons resize too big and occupy a heap of screen real estate when you do that so i'll take the minimalist approach if i can and see about snapping those to mini icons by user interaction (usually the << icon)

The error (and note, i have given this dir all permissions available, admin/root with full management (similar to grant/super etc, the max possible) so that usually means it's a lock, and verifying just now that dir is locked. So the delete/create usage probably just locked the file node for that dir (but Unity can still see the content, oddly):

UnauthorizedAccessException: Access to the path "Assets\FSP\MAST/Etc/Temp" is denied.
System.IO.Directory.CreateDirectoriesInternal (System.String path) (at <a8ed250850854b439cedc18931a314fe>:0)
System.IO.Directory.CreateDirectory (System.String path) (at <a8ed250850854b439cedc18931a314fe>:0)
MAST_Interface_State_Save.Save_Palette_State (System.Boolean forceSave) (at Assets/FSP/MAST/Scripts/Interface/MAST_Interface_State_Save.cs:46)
MAST_Interface.DisplayToolbarGUI () (at Assets/FSP/MAST/Scripts/Interface/MAST_Interface.cs:876)
MAST_Interface.OnGUI () (at Assets/FSP/MAST/Scripts/Interface/MAST_Interface.cs:615)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <a8ed250850854b439cedc18931a314fe>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <a8ed250850854b439cedc18931a314fe>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <a8ed250850854b439cedc18931a314fe>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:337)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:331)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:307)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:373)
UnityEditor.DockArea.OldOnGUI () (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:340)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:298)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:483)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:466)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:447)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/Events/MouseCaptureDispatchingStrategy.cs:93)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:280)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:156)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:190)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:255)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

I really need to quit reading your posts when I first wake up lol

Mine throws no error.  If this is a permissions issue, it could be the location of your project in the Windows folder structure.  It may only allow Unity's native method of folder management.

I'm just attempting to clear the contents of MAST/etc/temp, so if there's a safer way than deleting/recreating the folder, please let me know.

Your post really was nightmarish to read on my phone though.  I was joking but not really about bullet points before.

lol ok :)  probably best i just write the code and send it to you :)

That would work!  I will add you as a contributor in a comment above the code block.

Here's an old script illustrating how a mesh can be recalculated/rebounded, i'll add this into the system shortly.

(1 edit)

Ok i have a working mass object pivot centering but the problem is more involved, there's a lot of really badly designed workflows in Unity which prohibit automation/mass execution, they've done a lot to reduce it but the ghosts are still in there and i wouldn't feel comfortable asking people to go through separate steps, would rather have in a discrete scripted workflow, so i'll have to build an explicit splitter to create the assets and materials so it acts sort of like a tile splitter but for 3d objects. But so far this manual workflow is much faster now, i can export all the objects from a single bulk model with an array of submeshes then use my mesh remapper to set the pivots then your prefab tool and then alter materials, but what would be awesome would be a pallet selector for materials, so you dont just select a model you select geometry and a material, defaulting to the original material. I also need to look at ray casting edge snapping for objects that don't conform to grid, but conform to other models, like pipes etc.

I was thinking about a material painter option, but it would be optional and only paint over an existing material with another. 

Friend me on Discord:  Keith at FSP#5441

We can discuss some of your ideas there