Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Spine Objects work as expect in editor, invisible in Build

Discussion in 'Animation' started by DTECTOR, Jul 27, 2022.

  1. DTECTOR

    DTECTOR

    Joined:
    Aug 23, 2020
    Posts:
    132
    I am using Spine Runtimes for 4.0

    When I run the program from the editor, spine objects work as expected, a simple animation on loop. However in the build, every Spine Object is invisible, not visible, nothing visually is shown.

    I don't have any errors or anything. I am trying to find some answers but I have yet to find anyone that has this issue that didn't resolve it without something that appeared to be human error, such as switching the game object to editor only in tags or something with the competition of layers/hierarchy.

    I created the initial object by dragging the spine data object into the scene and clicking on the spine animation object and then I prefab it and store that in a scriptable object that holds all the data of a particular character/creature I store the entire gameobject rather than any spine related class. Maybe that is the issue? It seemed like that was the recommended way to handle Spine Objects as the docs specifically state that instantiating them from their base parts from the runtime api is not recommended.

    I just followed their own documentation and the "Getting Started" area in particular.

    With how big Unity I know there are a lot of gaps in my knowledge so if anyone has ever run into something like this and figured it out I would love to hear from you.

    One of the current things I am looking into is if it has anything to do with using Universal Render Pipeline (URP) as opposed to the old render pipeline. I've seen people run into issue with compatibility/breaking particularly on materials/shaders on the switch.
     
  2. KuldeepUnityEvon

    KuldeepUnityEvon

    Joined:
    Dec 13, 2023
    Posts:
    2
    The Same issue I am facing
     
  3. J_Kasowski

    J_Kasowski

    Joined:
    Jan 3, 2023
    Posts:
    18
    How are you assigning the shaders/materials? If it's scripting you need to have it in a folder that's transferred to the built project (I believe)... E.g. put the materials in a "Resources" folder and load them from there vs hardcoding a path (since a built project will no longer use the same Application.datapath).

    If that's not your issue, I don't know what it could be. More info might help

    EDIT: I am not sure what I read but I didn't read your whole post lol...

    It sounds like you are not scripting the creation of materials so I don't know how to help :(
     
  4. DTECTOR

    DTECTOR

    Joined:
    Aug 23, 2020
    Posts:
    132
    Hey there, I actually figured this out quite a while ago. Here are some of the potential issues that might be your fix:

    1. Check your z axis. A lot of times whether as a bug/glitch or I accidentally manually move the object where it somehow alters the z axis. I try to keep my z axis a 0 or 1 because if it's too far out from the clipping plane it will not render on the game camera but will show in scene view in editor. (This is an issue I always run into, almost every day when position new things in a scene, I often have scripts that automatically iterate through gameobjects in scene during editor validation and set the z axis to 0 or 1 just to stop it from randomly being -486.4 for something ridiculous)

    2. How are you anchoring the position? I was setting the position relative to gui elements from a canvas, I was converting the points correctly, however, what I had not thought about was the canvas scaling. If your canvas scaling is not identical to your game screen resolution it's going to alter where that position is in relation to the screen in world space. (This was my issue) It was sending my spine objects way off screen. This also falls into the issue with the z axis as you can have objects with bad z axis, sometimes they will even render but you assign the whole pos including the z to another object and that one disappears.

    3. Corrupted or messed up exports can cause the materials to not be attached or set if the atlas file is bugged. This has happened to me many times although I usually get a pop up message telling me during import and the spine object is usually pink in the scene view.

    And then lastly, the reason why it only occurred for me in the build, it's been a while so I can't remember the exact details but it was throwing a silent error that the editor was ignoring, but in the build it just fails and the rest of the code doesn't even run for the method so when I wasn't mis-assigning the position, it was due to the code for instantiating the spine objects in x position, it was just skipping that code altogether.

    It took me a real long time to figure this out. I spent probably almost 200 hrs on this problem due to being completely ignorant to all the potential elements that could be causing the issue, but now I will never ever not check these things so it's a good thing to learn and the pain only reinforces the lesson.
     
  5. DTECTOR

    DTECTOR

    Joined:
    Aug 23, 2020
    Posts:
    132