Skinned Mesh Renderer only appears if it's visible in the Scene window
Asked Answered
O

5

0

So, I’ve got an animated knife as a child of the first person camera. When I click, the knife swings. Everything works great! Except when the scene view isn’t pointed at my player…


If I play the game in a maximized game window, the knife doesn’t render. If I don’t play maximized, but don’t have the scene window on screen, the knife doesn’t render. If I walk out of view of the scene window, the knife doesn’t render.


It’s acting as if the scene view is my “camera,” and when the skinned mesh renderer isn’t displayed by that “camera” it doesn’t render. You’d expect this behavior but with the actual camera instead of the scene view.


I’ve never run into a problem like this before, so I’m very very confused. I’m sure there’s a setting or something that I’m overlooking. Any help is greatly appreciated :slight_smile:

Oneway answered 8/9, 2023 at 6:5 Comment(0)
O
0

Alright everyone, I’ve found a solution.

I don’t know exactly what fixed it, but I’ve changed a bunch of settings on the knife and camera. For anyone with a similar problem, here are the settings I suspect have something to do with it.

  • The Animator component has Culling Mode set to Always Animate.
  • The Skinned Mesh Renderer has Update When Offscreen checked true.
  • The Skinned Mesh Renderer has Dynamic Occluded set to false.
  • The Camera has Occlusion Culling set to true.
  • The Camera has Allow Dynamic Resolution set to false.

I’ll mark this answer as correct and leave the question here so it might help someone else.

Oneway answered 8/9, 2023 at 6:6 Comment(2)

All points are valid regarding Skinned Mesh Renderer. The Animator component has Culling Mode set to Always Animate. The Skinned Mesh Renderer has Update When Offscreen checked true. The Skinned Mesh Renderer has Dynamic Occluded set to false. The Camera has Occlusion Culling set to true. The Camera has Allow Dynamic Resolution set to false.

Acro

Always Animate on the Animator fixed for me

Sherlynsherm
L
0

Thanks hawksandwichgames your solution worked

Linzy answered 9/9, 2020 at 20:42 Comment(0)
H
0

@Oneway Actually only the

  • The Skinned Mesh RendererUpdate When Offscreen → checked true

does the trick.

However, this isn’t the ideal solution because it lowers the performance as the mesh bounds are remapped all the time. It’s ok if that happens for a single mesh but when you have them hundreds it can really impact the framerate.

Check: Unity - Manual: Skinned Mesh Renderer component
and Unity - Manual: Skinned Mesh Renderer component

the mesh is remapped when Update When Offscreen is set to true, when you set it back to false the bounds get to the original position.

in previous versions of Unity you could recalculate the bounds with this bit of code.

modelObject.GetComponent<SkinnedMeshRenderer>().sharedMesh.RecalculateBounds();

And that would be great so that I could remap the bounds when the animation happens. However, it doesn’t work anymore, or at least not for me…

Hepzi answered 8/9, 2023 at 6:8 Comment(1)
I
0

For Anyone who’s facing this issue.

U need to set the rootbone position of the attached object to the position of the Main SkinnedMeshrenderer rootbone position

Example:

O1 = Main.GetComponent<SkinnedMeshRenderer>();
O2 = Attached.GetComponent<SkinnedMeshRenderer>();
O2.rootBone.transform.position = O1.rootBone.transform.position;
Isopropanol answered 8/9, 2023 at 6:9 Comment(0)
L
0

Looks like an Editor bug for me.
Nothing helped except this workaround.

Script attached to SkinnedMeshRenderer gameObject:

using UnityEngine;
  
[RequireComponent( typeof(SkinnedMeshRenderer) )]
public class ForceUpdateSkinnedMesh : MonoBehaviour
{
    [SerializeField]
    SkinnedMeshRenderer skinnedMesh;
  
    void Update()
    {
        skinnedMesh.enabled = false;
    }
  
    void OnRenderObject()
    {
        skinnedMesh.enabled = true;
    }
}
Lorenz answered 8/9, 2023 at 6:2 Comment(3)

10kb as the file size of your source PNG/JPG/etc files is one thing, but they become a different format when they go into a game engine. Compressed formats like PNG don't live on the graphics card, they get turned into DXT/ETC/PVRTC/etc other formats that read/write faster depending on your target platform. A good starting point to fix this is to pack your textures https://docs.unity3d.com/2017.3/Documentation/Manual/SpritePacker.html and set the image compression reasonably high in your project asset settings (crunched, compressed, low/medium quality is a good start).

Handcar

Turn on profiler before you load the scene and watch the Memory section. Back to the original post, your scene loading is slow because there's a lot of data to be loaded using the frame-by-frame animation approach. Please accept my answer if you feel it's accurate, thanks.

Handcar

It's working, i I just add * The Animator component has Culling Mode set to Always Animate.

Cupcake

© 2022 - 2025 — McMap. All rights reserved.